NPM publish using OIDC on github actions
permissions:
contents: write
id-token: writejobs:
npm-publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: 'https://registry.npmjs.org'
# npm@v11.5.0+ is required for OIDC support
# node@v22.0.0+
# - name: Upgrade npm for OIDC support
# run: npm install -g npm@latest
# node@v24.0.0+
# https://github.com/orgs/community/discussions/176761
# https://github.com/actions/setup-node/issues/1440#issuecomment-3571890875
- run: NODE_AUTH_TOKEN="" npm publish --access public --provenance
name: π¦ hotkeys-js to NPM
continue-on-error: true
A few tips!
node-version: 24, you don't even have to upgrade npm since it is already in the version covering OIDC--access publiccan be defined inpackage.jsonand is only required on first publish to know the access type of your package if you're using a scope (@)--provenanceis by default when using OIDCcontents: write, onlycontents: readis enough!Here's one I wrote for one of my packages