Skip to content

ci: migrate npm release to OIDC trusted publishing with provenance#140

Merged
jaredwray merged 1 commit into
mainfrom
claude/serene-hamilton-qfdy65
Jun 12, 2026
Merged

ci: migrate npm release to OIDC trusted publishing with provenance#140
jaredwray merged 1 commit into
mainfrom
claude/serene-hamilton-qfdy65

Conversation

@jaredwray

Copy link
Copy Markdown
Contributor

Summary

Migrates the release workflow from a long-lived NPM_TOKEN to npm trusted publishing (OIDC) and enables provenance attestations on every publish.

With trusted publishing, GitHub Actions mints a short-lived OIDC token that npm exchanges for ephemeral publish credentials — no secret to rotate or leak. Provenance attestations cryptographically link each published version back to the exact commit and workflow run that built it (the green "provenance" badge on npmjs.com).

Changes

.github/workflows/release.yaml

  • Add id-token: write permission (keeps contents: read) so the job can mint an OIDC token.
  • Set registry-url: 'https://registry.npmjs.org' on setup-node (per npm's trusted-publishing guidance).
  • Add an Update npm step (npm install -g npm@latest) — trusted publishing requires npm CLI ≥ 11.5.1, newer than the version bundled with Node.js 22.
  • Publish via npm publish --provenance --ignore-scripts and remove the NPM_TOKEN secret and the npm config set //registry.npmjs.org/:_authToken step.

package.json

  • Add a public repository field (plus homepage and bugs). A repository field that matches the source repo case-sensitively (Hyphen/nodejs-sdk) is required for npm to generate provenance attestations.

⚠️ Required one-time setup before the next release

The workflow change alone is not sufficient — a trusted publisher must be configured on npm, otherwise the publish will fail with an auth error. On https://www.npmjs.com/package/@hyphen/sdkSettings → Trusted Publisher, add a GitHub Actions publisher with:

Field Value
Organization or user Hyphen
Repository nodejs-sdk
Workflow filename release.yaml
Environment name (leave blank — none is used)

The NPM_TOKEN repository secret can be deleted once this is in place.

Verification

  • pnpm build — succeeds
  • pnpm test — lint clean, 233 tests pass, 100% coverage (statements/branches/functions/lines)

References

https://claude.ai/code/session_016qHimevBQJsTHzBxV7B2od


Generated by Claude Code

- Add `id-token: write` permission so the workflow can mint an OIDC token
- Set `registry-url` on setup-node and upgrade npm to the latest (>= 11.5.1),
  which is required for trusted publishing
- Publish with `--provenance` and drop the long-lived `NPM_TOKEN` secret;
  authentication is now handled via OIDC trusted publishing
- Add `repository` (plus `homepage`/`bugs`) to package.json — a public
  `repository` field matching the source repo is required to generate
  provenance attestations

https://claude.ai/code/session_016qHimevBQJsTHzBxV7B2od
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (19f5c37) to head (de6caf4).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #140   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            8         8           
  Lines          492       492           
  Branches       105       105           
=========================================
  Hits           492       492           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

# Trusted publishing (OIDC) requires npm CLI >= 11.5.1, which is newer than
# the version bundled with Node.js 22.
- name: Update npm
run: npm install -g npm@latest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pnpm instead. add in pnpm/setup action

- name: Publish
# No NPM_TOKEN: authentication is handled via OIDC trusted publishing.
# Provenance attestations are generated from the OIDC identity.
run: npm publish --provenance --ignore-scripts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pnpm

@jaredwray jaredwray merged commit 522537b into main Jun 12, 2026
9 of 12 checks passed
@jaredwray jaredwray deleted the claude/serene-hamilton-qfdy65 branch June 12, 2026 16:55
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