This repository was archived by the owner on Aug 6, 2026. It is now read-only.
Repository navigation
feat(code): harden branch linking during PR creation flow #483
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tag PostHog Code Release | |
| on: | |
| schedule: | |
| - cron: "0 1,17 * * *" | |
| workflow_dispatch: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| concurrency: | |
| group: code-tag | |
| cancel-in-progress: false | |
| jobs: | |
| tag: | |
| if: >- | |
| github.event_name == 'schedule' || | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.pull_request.merged == true && | |
| contains(github.event.pull_request.labels.*.name, 'Create release')) | |
| permissions: | |
| contents: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get app token | |
| id: app-token | |
| uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3 | |
| with: | |
| app_id: ${{ secrets.GH_APP_ARRAY_RELEASER_APP_ID }} | |
| private_key: ${{ secrets.GH_APP_ARRAY_RELEASER_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Compute version and create tag | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| REPOSITORY: ${{ github.repository }} | |
| run: | | |
| # Find the latest base version tag (vX.Y or vX.Y.0 format) | |
| LATEST_TAG=$(git tag --list 'v[0-9]*.[0-9]*' --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+(\.0)?$' | head -1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| echo "No version tag found. Create one with: git tag v0.15 && git push origin v0.15" | |
| exit 1 | |
| fi | |
| # Extract major.minor from tag | |
| VERSION_PART=${LATEST_TAG#v} | |
| MAJOR=$(echo "$VERSION_PART" | cut -d. -f1) | |
| MINOR=$(echo "$VERSION_PART" | cut -d. -f2) | |
| # Count commits since the base tag | |
| PATCH=$(git rev-list "$LATEST_TAG"..HEAD --count) | |
| if [ "$PATCH" -eq 0 ]; then | |
| echo "No commits since $LATEST_TAG. Nothing to release." | |
| exit 0 | |
| fi | |
| NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| TAG="v$NEW_VERSION" | |
| echo "Creating tag: $TAG (from base tag $LATEST_TAG + $PATCH commits)" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push "https://x-access-token:${GH_TOKEN}@github.com/$REPOSITORY" "$TAG" |