Release/v3.0.1 #5
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 Release Merge | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - master | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| create-tag: | |
| # Only run when a release/* branch was actually merged (not just closed) | |
| if: > | |
| github.event.pull_request.merged == true && | |
| startsWith(github.event.pull_request.head.ref, 'release/') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Extract version from branch name | |
| id: version | |
| run: | | |
| BRANCH="${{ github.event.pull_request.head.ref }}" | |
| VERSION="${BRANCH#release/}" | |
| VERSION="${VERSION#v}" | |
| echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "TAG=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| echo "Detected version: $VERSION (tag: v${VERSION})" | |
| - name: Check if tag already exists | |
| id: check | |
| run: | | |
| if git rev-parse "refs/tags/${{ steps.version.outputs.TAG }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> "$GITHUB_OUTPUT" | |
| echo "Tag ${{ steps.version.outputs.TAG }} already exists, skipping." | |
| else | |
| echo "exists=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create and push tag | |
| if: steps.check.outputs.exists == 'false' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "${{ steps.version.outputs.TAG }}" -m "Release ${{ steps.version.outputs.VERSION }}" | |
| git push origin "${{ steps.version.outputs.TAG }}" |