Skip to content

Publish to npm via OIDC Trusted Publishing#21

Merged
msilivonik-sc merged 1 commit into
mainfrom
ms/npm-trusted-publishing
May 20, 2026
Merged

Publish to npm via OIDC Trusted Publishing#21
msilivonik-sc merged 1 commit into
mainfrom
ms/npm-trusted-publishing

Conversation

@msilivonik-sc
Copy link
Copy Markdown
Collaborator

Summary

  • Switch the npm publish workflow from a long-lived NPM_TOKEN secret to short-lived OIDC tokens via npm Trusted Publishing.
  • Grant id-token: write, upgrade npm to @latest (Trusted Publishing needs npm >= 11.5.1; Node 20 ships with npm 10), drop NODE_AUTH_TOKEN, and add --provenance for attestation.

Required setup on npmjs.com

Before the next release tag is pushed, configure @snap/ts-inject as a Trusted Publisher:

  1. npmjs.com → package settings → Publishing accessAdd trusted publisher → GitHub Actions
  2. Org: Snapchat, Repo: ts-inject, Workflow filename: npm.yaml, Environment: blank
  3. After the first successful OIDC publish, delete the NPM_TOKEN repo secret.

Test plan

  • Trusted Publisher configured on npmjs.com pointing at npm.yaml
  • Re-tag v1.0.0 and confirm the workflow publishes via OIDC
  • Verify the published version carries a provenance badge
  • Remove NPM_TOKEN repo secret after first successful publish

Replace the long-lived NPM_TOKEN secret with short-lived OIDC tokens
exchanged with npm at publish time. Grants the job id-token: write,
upgrades npm to the latest version (Trusted Publishing requires
npm >= 11.5.1; Node 20 ships with npm 10), drops NODE_AUTH_TOKEN, and
adds --provenance for attestation.

Requires the package to be configured as a Trusted Publisher on
npmjs.com pointing at this repo and workflow filename (npm.yaml).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@msilivonik-sc msilivonik-sc requested a review from kburov-sc May 20, 2026 20:36
@msilivonik-sc msilivonik-sc merged commit 9616a63 into main May 20, 2026
1 check passed
@msilivonik-sc msilivonik-sc deleted the ms/npm-trusted-publishing branch May 20, 2026 20:42
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