chore: release v0.5.0 #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
| name: Auto-release following a release commit | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| paths: | |
| - 'docs/CHANGELOG.md' | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| RELEASE_VERSION: ${{ steps.parse_commit.outputs.RELEASE_VERSION }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Parse commit message to get version | |
| id: parse_commit | |
| run: | | |
| # Commit message must be in the format of | |
| # "chore: release vX.X" | |
| VERSION=$(echo "$COMMIT_MESSAGE" | grep -oP '^chore:\ release\ v[a-zA-Z0-9.\-\+]+' | head -n 1 | cut -d' ' -f3) | |
| if [[ -z "$VERSION" ]]; then | |
| echo "Commit message does not match the expected format. Please use 'chore: release vX.X.X' format in your commit message." | |
| echo "Commit message: $COMMIT_MESSAGE" | |
| exit 1 | |
| fi | |
| echo "RELEASE_VERSION=$VERSION" >> "$GITHUB_OUTPUT" | |
| env: | |
| # Avoid script injection by using an environment variable | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| - name: Parse CHANGELOG.md to get release notes | |
| id: parse_changelog | |
| uses: kiyoon/parse-changelog-action@v1 | |
| with: | |
| changelog-file-path: docs/CHANGELOG.md | |
| version: ${{ steps.parse_commit.outputs.RELEASE_VERSION }} | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.parse_commit.outputs.RELEASE_VERSION }} | |
| name: ${{ steps.parse_commit.outputs.RELEASE_VERSION }} | |
| body: ${{ steps.parse_changelog.outputs.body }} | |
| deploy-mkdocs: | |
| needs: release | |
| uses: deargen/workflows/.github/workflows/deploy-mkdocs.yml@master | |
| with: | |
| requirements-file: deps/lock/x86_64-manylinux_2_28/requirements_docs.txt | |
| gitlab-project: ${{ vars.GITLAB_PROJECT }} | |
| gitlab-branch: master | |
| version-tag: ${{ needs.release.outputs.RELEASE_VERSION }} | |
| deploy-type: tag | |
| secrets: | |
| GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} |