Release #2
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: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'SemVer version (e.g. 1.0.0)' | |
| required: true | |
| type: string | |
| push: | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| permissions: | |
| contents: read | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "tag=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Validate SemVer format | |
| run: | | |
| if ! echo "${{ steps.version.outputs.tag }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | |
| echo "Error: Version must be in SemVer format MAJOR.MINOR.PATCH (e.g. 1.0.0)" | |
| exit 1 | |
| fi | |
| - name: Create and push tag | |
| if: github.event_name == 'workflow_dispatch' | |
| run: | | |
| git tag "${{ steps.version.outputs.tag }}" | |
| git push origin "${{ steps.version.outputs.tag }}" | |
| - name: Get previous tag | |
| id: previous | |
| run: | | |
| PREVIOUS=$(git tag --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | grep -v "^${{ steps.version.outputs.tag }}$" | head -1) | |
| echo "tag=$PREVIOUS" >> "$GITHUB_OUTPUT" | |
| - name: Generate changelog | |
| id: changelog | |
| uses: requarks/changelog-action@v1 | |
| with: | |
| token: ${{ github.token }} | |
| fromTag: ${{ steps.version.outputs.tag }} | |
| toTag: ${{ steps.previous.outputs.tag }} | |
| excludeTypes: build,docs,other,style,ci,chore | |
| useGitmojis: false | |
| writeToFile: true | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} | |
| name: ${{ steps.version.outputs.tag }} | |
| body: ${{ steps.changelog.outputs.changes }} | |
| - name: Commit updated CHANGELOG | |
| uses: stefanzweifel/git-auto-commit-action@v7 | |
| with: | |
| branch: main | |
| commit_message: "docs: update CHANGELOG for ${{ steps.version.outputs.tag }}" | |
| file_pattern: CHANGELOG.md |