Skip to content

ci: fix publish job permissions for semantic-release #36

ci: fix publish job permissions for semantic-release

ci: fix publish job permissions for semantic-release #36

Workflow file for this run

name: NPM package Publish
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
quality:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ lts/* ]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run build
- run: npm test --if-present
publish:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ quality ]
permissions:
contents: write # semantic-release needs to push version tags back to main
issues: write # semantic-release comments on GitHub issues
pull-requests: write # semantic-release comments on PRs
id-token: write # OIDC trusted publishing
steps:
- uses: actions/checkout@v4
- name: Use Node.js (LTS)
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "npm"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run build
- run: npm run semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # keep for semantic-release (see note below)
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}