auto-tag #62
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: auto-tag | |
| on: | |
| workflow_run: | |
| workflows: [ci] | |
| types: [completed] | |
| permissions: | |
| actions: write | |
| contents: write | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true' | |
| jobs: | |
| tag: | |
| if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| fetch-depth: 2 | |
| - name: Check package version changed | |
| id: changed | |
| run: | | |
| if git diff --quiet HEAD^ HEAD -- packages/core/package.json; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Read version | |
| if: steps.changed.outputs.changed == 'true' | |
| id: version | |
| run: echo "version=$(node -p "require('./packages/core/package.json').version")" >> "$GITHUB_OUTPUT" | |
| - name: Verify release metadata before tagging | |
| if: steps.changed.outputs.changed == 'true' | |
| env: | |
| TAG: v${{ steps.version.outputs.version }} | |
| run: node scripts/verify-release.mjs --tag "$TAG" | |
| - name: Create and push tag if missing | |
| if: steps.changed.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAG: v${{ steps.version.outputs.version }} | |
| run: | | |
| if git ls-remote --tags origin "$TAG" | grep -q "$TAG"; then | |
| echo "Tag $TAG already exists — skipping" | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$TAG" -m "release $TAG" | |
| git push origin "$TAG" | |
| gh workflow run release.yml --ref "$TAG" | |
| fi |