Update npm publish command in release workflow #106
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: Publish | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - develop | |
| - master | |
| permissions: | |
| contents: write # to be able to publish a GitHub release | |
| issues: write # to be able to comment on released issues | |
| pull-requests: write # to be able to comment on released pull requests | |
| id-token: write # to enable use of OIDC for trusted publishing and npm provenance | |
| env: | |
| GIT_AUTHOR_NAME: "@swisspost-devs" | |
| GIT_AUTHOR_EMAIL: "oss@post.ch" | |
| GIT_COMMITTER_NAME: "swisspost-devs" | |
| GIT_COMMITTER_EMAIL: "oss@post.ch" | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| environment: npm-release | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Setup node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: | | |
| rm -rf node_modules | |
| npm i node@v20-lts --no-save | |
| # Trusted publishing requires npm 11.5.1 or later. | |
| - name: Update NPM for trusted publishing | |
| run: | | |
| npm update -g npm | |
| echo "npm: $(npm -v)" | |
| - name: Release (dry-run) | |
| if: github.event_name == 'pull_request' | |
| run: npm publish --dry-run --provenance | |
| - name: Release | |
| if: github.event_name == 'push' | |
| run: npm publish --provenance |