Skip to content

Publish to npm with OIDC trusted publishing - #957

Closed
graygilmore wants to merge 2 commits into
mainfrom
gg-npm-oidc-publishing
Closed

graygilmore wants to merge 2 commits into
mainfrom
gg-npm-oidc-publishing

Conversation

@graygilmore

@graygilmore graygilmore commented Sep 11, 2026

Copy link
Copy Markdown

Both publishing workflows in this repo still authenticate to npm with the NPM_TOKEN secret. npm's recommended path for CI publishing is now trusted publishing (OIDC), which is what hydrogen and theme-tools already use, so this PR moves both workflows over:

  • npm-release.yml: sets NPM_TOKEN: '' so changesets/action skips writing a token to .npmrc and npm falls through to OIDC. changesets/action moves to v1.9.0 because that path only exists from v1.7.0. setup-node gets registry-url so the CLI knows which registry to exchange the OIDC token with.
  • snapit.yml: bumps Shopify/snapit to v0.1.0, which dropped NPM_TOKEN support and publishes over OIDC. The github_comment_included_packages input was renamed to comment_packages in that release.

Before merging

Trusted publishing is configured per package and per workflow file on npmjs.com, so @shopify/buy-button-js needs both npm-release.yml and snapit.yml registered for this repo before this lands. Otherwise the next publish fails with ENEEDAUTH. That happens on the npm side, not in this diff.

Once the first OIDC publish goes through, the NPM_TOKEN repo secret can be deleted.

Reviewer notes

This overlaps with #952, which makes the same npm-release.yml change as part of a larger modernization stack. This PR is intentionally standalone against main so it can land on its own. Happy to drop it if that stack is close to landing.

issue_comment workflows always run from main, so the snapit.yml change can't be tried on this PR. The Force snapshot step also still writes to snapshot.txt instead of .changeset/, which I don't think does anything; left alone since it's unrelated.

The snapit workflow authenticated to npm with the long-lived NPM_TOKEN
secret. Shopify/snapit v0.1.0 dropped token support and publishes over
OIDC instead, so this bumps the action, points setup-node at the npm
registry so the CLI can complete the OIDC exchange, and drops the token
from the step. The comment_packages input replaces the renamed
github_comment_included_packages.

Assisted-By: devx/d9810122-2b8f-4f8d-b51b-eb980219e4b6
The release workflow already requested id-token: write for provenance
but still authenticated the publish with NPM_TOKEN. Set NPM_TOKEN to an
empty string so changesets/action skips writing a token to .npmrc and
lets npm fall through to OIDC, and add registry-url so setup-node
configures the registry the CLI exchanges the token with.

changesets/action moves to v1.9.0 because token-less publishing only
became a supported path in v1.7.0.

Assisted-By: devx/d9810122-2b8f-4f8d-b51b-eb980219e4b6
Comment thread .github/workflows/npm-release.yml
@kdaviduik

Copy link
Copy Markdown
Contributor

#952 merged

@kdaviduik kdaviduik closed this Sep 15, 2026
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.

3 participants