|
| 1 | +# |
| 2 | +# GitHub action for executing "semantic-release" with configuration in ".releaserc.json" |
| 3 | +# |
| 4 | +# Note about pushing to protected branches: |
| 5 | +# |
| 6 | +# The GITHUB_TOKEN credential does not have the required permission |
| 7 | +# to operate on protected branches. |
| 8 | +# Solution: |
| 9 | +# 1. generate a GitHub Personal Access Token |
| 10 | +# 2. and register it as a Repository Secrets and name it `SEMANTIC_RELEASE_GH_TOKEN` |
| 11 | +# 3. Important: set "actions/checkout" to "persist-credentials: false" otherwise it will be overwriten |
| 12 | +# |
| 13 | +# Reference |
| 14 | +# - https://conventionalcommits.org |
| 15 | +# - https://semantic-release.gitbook.io |
| 16 | +# - https://semantic-release.gitbook.io/semantic-release/recipes/ci-configurations/github-actions |
| 17 | +# - https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line |
| 18 | +# |
| 19 | + |
| 20 | +name: Semantic-release |
| 21 | + |
| 22 | +on: |
| 23 | + push: |
| 24 | + branches: |
| 25 | + - main |
| 26 | + |
| 27 | +permissions: |
| 28 | + contents: read # for checkout |
| 29 | + |
| 30 | +jobs: |
| 31 | + release: |
| 32 | + name: Semantic-release |
| 33 | + runs-on: ubuntu-latest |
| 34 | + permissions: |
| 35 | + contents: write # to be able to publish a GitHub release |
| 36 | + issues: write # to be able to comment on released issues |
| 37 | + pull-requests: write # to be able to comment on released pull requests |
| 38 | + id-token: write # to enable use of OIDC for npm provenance |
| 39 | + steps: |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + persist-credentials: false |
| 45 | + - name: Setup Node.js |
| 46 | + uses: actions/setup-node@v4 |
| 47 | + with: |
| 48 | + node-version: "latest" |
| 49 | + - name: Install semantic-release |
| 50 | + run: npm install --save-dev semantic-release |
| 51 | + - name: Install semantic-release additional plugins (git) |
| 52 | + run: npm install @semantic-release/git |
| 53 | + - name: Install semantic-release additional plugins (changelog) |
| 54 | + run: npm install @semantic-release/changelog -D |
| 55 | + - name: Install semantic-release additional plugins (semantic-release-replace-plugin) |
| 56 | + run: npm install semantic-release-replace-plugin -D |
| 57 | + - name: Install semantic-release additional plugins (conventional-changelog-conventionalcommits for commit-analyzer preset) |
| 58 | + run: npm install conventional-changelog-conventionalcommits -D |
| 59 | + - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies |
| 60 | + run: npm audit signatures |
| 61 | + - name: Release |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GH_TOKEN }} |
| 64 | + run: npx semantic-release |
| 65 | + |
0 commit comments