Create Major Release Tag #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: Create Major Release Tag | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| tag-major: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Clone repo, pull all commits, branches, and tags | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Calculate next major version (vX.0.0) | |
| id: bump | |
| run: | | |
| latest_tag=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1) | |
| [ -z "$latest_tag" ] && latest_tag="v0.0.0" | |
| echo "Latest tag: $latest_tag" | |
| major=${latest_tag#v} | |
| major=${major%%.*} | |
| new_major=$((major + 1)) | |
| new_tag="v${new_major}.0.0" | |
| echo "new_tag=$new_tag" >> $GITHUB_OUTPUT | |
| - name: Commit and tag changes | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| tagging_message: ${{ steps.bump.outputs.new_tag }} | |
| create_git_tag_only: true | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.bump.outputs.new_tag }} | |
| name: ${{ steps.bump.outputs.new_tag }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |