Skip to content

feat: use npm trusted publishing instead of NPM_TOKEN#678

Merged
morgante merged 1 commit intobiomejs:mainfrom
cogwirrel:feat/npm-trusted-publishing
Mar 30, 2026
Merged

feat: use npm trusted publishing instead of NPM_TOKEN#678
morgante merged 1 commit intobiomejs:mainfrom
cogwirrel:feat/npm-trusted-publishing

Conversation

@cogwirrel
Copy link
Copy Markdown
Contributor

@cogwirrel cogwirrel commented Mar 23, 2026

Summary

Switch from NPM_TOKEN-based authentication to npm trusted publishing (OIDC) for publishing to npm. This eliminates the need for long-lived npm access tokens and improves security.

Changes

  • Add registry-url: 'https://registry.npmjs.org' to actions/setup-node — required for OIDC token exchange
  • Install npm@11.6.1 which supports trusted publishing (reference: nx-plugin-for-aws CI)
  • Remove manual .npmrc token configuration (echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc)
  • Remove NPM_TOKEN secret usage — no longer needed with OIDC
  • Pass --provenance flag directly to npm publish commands
  • Keep existing id-token: write permission (already present)

How it works

Trusted publishing creates a trust relationship between npm and GitHub Actions using OIDC. When configured, npm accepts publishes from the authorized workflow using short-lived, cryptographically-signed tokens instead of long-lived access tokens. The npm CLI automatically detects the OIDC environment and uses it for authentication.

Setup steps

Before merging this PR, the platform-specific npm packages need to be created for the first time (most don't exist yet). Here's the suggested approach:

  1. Add an NPM_TOKEN to GitHub secrets and run the existing workflow as-is — this will publish all the new packages for the first time
  2. Set up trusted publishing for each of the npm packages via the npm website (package settings → Trusted Publishers → add biomejs/gritql repo with .github/workflows/napi.yaml workflow)
  3. Merge this PR and delete the NPM_TOKEN secret — trusted publishing handles auth from here on

Packages that already exist

  • @getgrit/gritql (v0.0.1)
  • @getgrit/gritql-darwin-arm64 (v0.0.0)

Packages that need to be created first (11)

@getgrit/gritql-win32-x64-msvc, @getgrit/gritql-darwin-x64, @getgrit/gritql-darwin-universal, @getgrit/gritql-linux-x64-gnu, @getgrit/gritql-linux-x64-musl, @getgrit/gritql-linux-arm64-gnu, @getgrit/gritql-linux-arm64-musl, @getgrit/gritql-win32-arm64-msvc, @getgrit/gritql-android-arm64, @getgrit/gritql-freebsd-x64, @getgrit/gritql-linux-riscv64-gnu

Switch from NPM_TOKEN-based authentication to npm trusted publishing
(OIDC) for publishing to npm. This eliminates the need for long-lived
npm access tokens and improves security.

Changes:
- Add registry-url to actions/setup-node for OIDC token exchange
- Install npm@11.6.1 which supports trusted publishing
- Remove manual .npmrc token configuration
- Remove NPM_TOKEN secret usage
- Pass --provenance flag directly to npm publish commands
- Keep id-token: write permission (already present)
@morgante morgante merged commit fa5e586 into biomejs:main Mar 30, 2026
24 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants