chore: sync cicd with toon4s #3
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
| # Auto tag - Automated semantic versioning based on conventional commits | |
| name: Auto tag | |
| on: | |
| push: | |
| branches: [main] | |
| concurrency: | |
| group: auto-tag-${{ github.ref }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| auto-tag: | |
| name: Create semantic version tag | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[skip release]')" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check and clean incomplete releases | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const tags = await github.rest.repos.listTags({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| per_page: 10 | |
| }); | |
| for (const tag of tags.data) { | |
| try { | |
| await github.rest.repos.getReleaseByTag({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag: tag.name | |
| }); | |
| } catch (error) { | |
| if (error.status === 404) { | |
| await github.rest.git.deleteRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: `tags/${tag.name}` | |
| }); | |
| } | |
| } | |
| } | |
| - name: Bump version and push tag | |
| id: tag_version | |
| uses: mathieudutour/github-tag-action@v6.2 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| default_bump: patch | |
| tag_prefix: v | |
| release_branches: main | |
| custom_release_rules: | | |
| feat:minor:Features, | |
| fix:patch:Bug Fixes, | |
| docs:patch:Documentation, | |
| chore:patch:Chores, | |
| refactor:patch:Refactoring, | |
| perf:patch:Performance, | |
| test:patch:Tests, | |
| build:patch:Build System, | |
| ci:patch:CI/CD, | |
| revert:patch:Reverts | |
| - name: Trigger release workflow | |
| if: steps.tag_version.outputs.new_tag != '' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.repos.createDispatchEvent({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| event_type: 'release-tag-created', | |
| client_payload: { | |
| tag: '${{ steps.tag_version.outputs.new_tag }}' | |
| } | |
| }); |