Tag and Release #1
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 and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v1.0.0)' | |
| required: true | |
| target_branch: | |
| description: 'Branch to tag (e.g., release)' | |
| default: release | |
| required: true | |
| jobs: | |
| tag_and_release: | |
| name: Tag and Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Check if tag already exists | |
| id: check_tag | |
| run: | | |
| if git rev-parse "refs/tags/${{ github.event.inputs.version }}" >/dev/null 2>&1; then | |
| echo "Tag already exists" | |
| echo "tag_exists=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Abort if tag exists | |
| if: steps.check_tag.outputs.tag_exists == 'true' | |
| run: exit 1 | |
| - name: Create and push tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin ${{ github.event.inputs.target_branch }} | |
| git checkout ${{ github.event.inputs.target_branch }} | |
| git tag ${{ github.event.inputs.version }} | |
| git push origin ${{ github.event.inputs.version }} | |
| - name: Create GitHub Release | |
| uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0 | |
| with: | |
| tag: ${{ github.event.inputs.version }} | |
| name: ${{ github.event.inputs.version }} | |
| body: "Automated release of version ${{ github.event.inputs.version }}" | |
| draft: false | |
| prerelease: false | |
| token: ${{ secrets.GITHUB_TOKEN }} |