Cut 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: Cut release | |
| on: | |
| workflow_dispatch: {} | |
| concurrency: release | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Mint App installation token | |
| id: app-token | |
| uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0 | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: ${{ github.event.repository.name }} | |
| permission-contents: write | |
| - uses: actions/checkout@v7.0.0 | |
| with: | |
| fetch-depth: 0 # need full tag history to compute the next serial | |
| token: ${{ steps.app-token.outputs.token }} | |
| persist-credentials: true | |
| - name: Compute CalVer tag | |
| id: version | |
| run: | | |
| YEAR_MONTH=$(date +'%y.%m') | |
| SERIAL=$(git tag -l "v${YEAR_MONTH}.[0-9]*" | sed -E "s/^v${YEAR_MONTH}\.//" | sort -n | tail -1) | |
| SERIAL=${SERIAL:-0} | |
| NEXT=$((SERIAL + 1)) | |
| TAG="v${YEAR_MONTH}.${NEXT}" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "Computed tag: $TAG" | |
| - name: Validate CalVer tag format | |
| env: | |
| TAG: ${{ steps.version.outputs.tag }} | |
| run: | | |
| if [[ ! "$TAG" =~ ^v[0-9]{2}\.(0[1-9]|1[0-2])\.[1-9][0-9]*$ ]]; then | |
| echo "::error::Tag '$TAG' does not match required CalVer format vYY.MM.SERIAL (e.g. v26.07.1)" | |
| exit 1 | |
| fi | |
| echo "Tag '$TAG' is valid." | |
| - name: Tag and push | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag ${{ steps.version.outputs.tag }} | |
| git push origin ${{ steps.version.outputs.tag }} | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| generate_release_notes: true |