version 1.6 #8
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 & Release | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| tag-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Check commit message and extract version | |
| id: get_version | |
| run: | | |
| MSG="$(git log -1 --pretty=%B)" | |
| if [[ "$MSG" =~ ^version[[:space:]]([0-9]+\.[0-9]+)$ ]]; then | |
| VERSION="v${BASH_REMATCH[1]}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "No version bump commit, skipping." | |
| exit 0 | |
| fi | |
| - name: Create Tag | |
| if: steps.get_version.outputs.version != '' | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAT }} | |
| run: | | |
| echo ${#GH_PAT} | |
| git config user.name "canrad" | |
| git config user.email "1517807724@qq.com" | |
| git remote set-url origin https://x-access-token:${GH_PAT}@github.com/${{ github.repository }}.git | |
| git tag ${{ steps.get_version.outputs.version }} | |
| git push origin ${{ steps.get_version.outputs.version }} | |
| - name: Create GitHub Release | |
| if: steps.get_version.outputs.version != '' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.get_version.outputs.version }} | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |