Semantic Release #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
| # This workflow is used to release a new version of the package to the main branch. | |
| # It follows the following steps: | |
| # - Merge PR/Push to main → semantic-release.yml → creates tag → calls docker-build.yml. | |
| # Reference: https://semantic-release.gitbook.io/semantic-release/recipes/ci-configurations/github-actions | |
| name: Semantic Release | |
| on: | |
| # Comment out this section so the release can be triggered manually. | |
| # push: | |
| # branches: | |
| # - main | |
| # workflow_run: | |
| # workflows: | |
| # - 'Push' | |
| # types: | |
| # - completed | |
| # branches: | |
| # - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write # Required: create tags, GitHub releases, and commit changes (git plugin) | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| env: | |
| HUSKY: 0 | |
| timeout-minutes: 15 | |
| outputs: | |
| new-release-published: ${{ steps.semantic-release.outputs.new-release-published }} | |
| new-release-version: ${{ steps.semantic-release.outputs.new-release-version }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.RELEASE_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Install semantic-release packages | |
| run: | | |
| npm install --no-save \ | |
| semantic-release@^24.2.5 \ | |
| @semantic-release/changelog@^6.0.3 \ | |
| @semantic-release/commit-analyzer@^13.0.1 \ | |
| @semantic-release/git@^10.0.1 \ | |
| @semantic-release/github@^11.0.3 \ | |
| @semantic-release/npm@^12.0.1 \ | |
| @semantic-release/release-notes-generator@^14.0.3 \ | |
| @semantic-release/exec@^7.1.0 | |
| - name: Verify npm audit | |
| run: npm audit signatures | |
| - name: Release | |
| id: semantic-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| npx semantic-release | |
| # Check if release output files created by @semantic-release/exec | |
| if [ -f "RELEASE_VERSION" ]; then | |
| VERSION=$(cat RELEASE_VERSION) | |
| echo "New release published: v$VERSION" | |
| echo "new-release-published=true" >> $GITHUB_OUTPUT | |
| echo "new-release-version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "No new release published" | |
| echo "new-release-published=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Call Docker workflow after successful release | |
| docker: | |
| needs: release | |
| if: needs.release.outputs.new-release-published == 'true' | |
| uses: ./.github/workflows/docker-build.yml | |
| with: | |
| tag-name: "v${{ needs.release.outputs.new-release-version }}" | |
| is-dev-release: false | |
| secrets: inherit |