Update npm publish command in release workflow #108
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: read # to be able to publish a GitHub release | |
| 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" | |
| # Trusted publishing requires npm 11.5.1 or later. | |
| - name: Update NPM for trusted publishing | |
| run: | | |
| npm install -g npm@latest | |
| echo "npm: $(npm -v)" | |
| - name: Install dependencies | |
| run: | | |
| rm -rf node_modules | |
| npm i node@v20-lts --no-save | |
| - name: Release (dry-run) | |
| if: github.event_name == 'pull_request' | |
| run: npm publish --dry-run | |
| - name: Release | |
| if: github.event_name == 'push' | |
| run: npm publish |