Skip to content

feat: update release workflow to enable trusted publishing #90

feat: update release workflow to enable trusted publishing

feat: update release workflow to enable trusted publishing #90

Workflow file for this run

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@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Setup node.js
uses: actions/setup-node@v2
with:
node-version: 20
- 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'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx @semantic-release/npm --dry-run --no-ci
- name: Release
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Override node 10 .npmrc created by Gihub Action
NPM_CONFIG_USERCONFIG: ./.npmrc
run: npx @semantic-release/npm