Skip to content

CHANGE @W-24708955@ Migrate npm publishing to Trusted Publishing (OIDC) - #2108

Draft
nikhil-mittal-165 wants to merge 5 commits into
devfrom
nikhil.mittal/npm-trusted-publishing
Draft

nikhil-mittal-165 wants to merge 5 commits into
devfrom
nikhil.mittal/npm-trusted-publishing

Conversation

@nikhil-mittal-165

@nikhil-mittal-165 nikhil-mittal-165 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ DO NOT MERGE YET

Platform CLI must first configure the trusted publisher on npmjs.com (see Merge order). The title has a placeholder GUS id (W-00000000) that must be replaced before the PR title check passes.

Why

The NPM_TOKEN used to publish @salesforce/plugin-code-analyzer expires Nov 12, 2026, and npm is ending publishes with bypass-2fa tokens in Jan 2027. Source: Platform CLI announcement in #C02JJPVHL7N (Katy Bowman) and the "Migrating to NPM trusted publishing" canvas. Reference: salesforcecli/plugin-api#228.

What changed

  • publish-to-npm.yml
    • publish-rc: add id-token: write, install npm@11, pass --trusted-publishing to sf-release, drop NPM_TOKEN.
    • promote-to-latest: add id-token: write, install npm@11, drop the .npmrc token write (npm dist-tag add now authenticates via OIDC).
    • verify-candidate-tag: drop the unneeded token on a read-only npm view.
  • apply-npm-tag-to-version.yml: use OIDC for npm dist-tag add instead of a token.
  • npm is pinned to 11 (npm@11 → 11.21.1, which has OIDC publish + dist-tag support) instead of latest. npm 12 removed npm shrinkwrap and no longer packs npm-shrinkwrap.json, which this plugin ships via prepack. On npm 11, npm shrinkwrap still works unchanged (verified on 11.21.1: output byte-identical to the shrinkwrap in published 5.16.0), so package.json is untouched.

Merge order

  1. Platform CLI registers the trusted publisher for @salesforce/plugin-code-analyzer on npmjs.com against workflow file publish-to-npm.yml, and a second entry for apply-npm-tag-to-version.yml. Both need "Allow npm dist-tag" enabled.
  2. Merge this PR.
  3. Trigger a real release within 24 hours of step 1, or the registration expires.

Open questions for Platform CLI

  • We pin npm 11 to keep shipping the shrinkwrap. Is that OK, or do you recommend dropping the shrinkwrap (as plugin-api/plugin-agent appear to) so we can use npm 12?
  • Does sf-release npm:package:release --sign --trusted-publishing need more than contents: read on the GitHub token (we scoped job permissions to id-token: write + contents: read)?
  • --sign (AWS keys) is kept alongside --trusted-publishing. I have not verified that combination end-to-end.
  • Not tested: this cannot be validated until the trusted publisher exists on npm.

🤖 Generated with Claude Code

nikhil-mittal-165 and others added 3 commits October 29, 2026 12:36
Replace the long-lived NPM_TOKEN with npm Trusted Publishing, ahead of the
Nov 12, 2026 token expiry and npm's bypass-2fa publish deprecation.

- publish-to-npm.yml: grant id-token: write, upgrade npm, pass
  --trusted-publishing to sf-release, drop NPM_TOKEN usage
- apply-npm-tag-to-version.yml: use OIDC for dist-tag instead of a token
- package.json: remove `npm shrinkwrap` (removed in npm 12)

Requires the trusted publisher to be configured on npmjs.com (with
"Allow npm dist-tag" enabled) before merging.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
npm 12 removed `npm shrinkwrap` and no longer packs npm-shrinkwrap.json, so
`npm@latest` would silently drop the pinned dependency tree this plugin ships.

- Install npm@11 (>= 11.21.0, which has OIDC dist-tag support) instead of latest
- Generate the shrinkwrap with `cp package-lock.json npm-shrinkwrap.json` in
  prepack; verified byte-identical to `npm shrinkwrap` output and to the
  shrinkwrap in the published 5.16.0 tarball
- Restore the /npm-shrinkwrap.json entry in `files` and its postpack cleanup

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
With npm pinned to 11, `npm shrinkwrap` still works (verified on 11.21.1:
output is byte-identical to the shrinkwrap in published 5.16.0), so the
`cp package-lock.json npm-shrinkwrap.json` workaround is unnecessary.
package.json is now unchanged from dev.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@nikhil-mittal-165 nikhil-mittal-165 changed the title CHANGE @W-00000000@ Migrate npm publishing to Trusted Publishing (OIDC) CHANGE @W-24708955@ Migrate npm publishing to Trusted Publishing (OIDC) Oct 29, 2026
nikhil-mittal-165 and others added 2 commits October 29, 2026 14:02
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Address SAST rule github-actions.security.run-shell-injection: move
github.event.inputs / release tag values out of direct ${{ }} interpolation
in run: steps and into env vars, quoted at use.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant