Skip to content

Npm trusted publish#1324

Draft
RembrandtK wants to merge 5 commits intomainfrom
npm-trusted-publish
Draft

Npm trusted publish#1324
RembrandtK wants to merge 5 commits intomainfrom
npm-trusted-publish

Conversation

@RembrandtK
Copy link
Copy Markdown
Contributor

Token-based auth using GRAPHPROTOCOL_NPM_TOKEN is no longer working and we need to migrate to NPM OIDC trusted publishing.

Changes

  • OIDC trusted publishing (a8ccc177d): Drop the npm token and authenticate via GitHub's OIDC. Adds id-token: write permission and --provenance to the publish command, which also attaches a sigstore attestation tying each tarball to this commit.
  • npm CLI upgrade (82cc38c77): pnpm publish shells out to npm for registry auth; npm ≥ 11.5.1 is required for OIDC trusted publishing, so we npm install -g npm@latest before publishing.
  • Workflow coverage (dcde8641a): Add address-book, interfaces, and toolshed to the package dropdown; add a dry_run input that runs pnpm publish --dry-run and skips the git tag step; on real runs, push a <pkg>@<version> git tag (requires contents: write).
  • pnpm version sync (9c1c689b8): Bump the corepack-activated pnpm in the setup action from 10.17.0 to 10.28.0 to match the repo's packageManager field, avoiding a version mismatch warning.

Enabling trusted publishing

Trusted publishing needs to be enabled per package on npmjs.com before the first run, otherwise auth will fail:

  • @graphprotocol/contracts — Settings → Trusted Publisher → GitHub Actions, repo graphprotocol/contracts, workflow publish.yml, env (none)
  • @graphprotocol/sdk
  • @graphprotocol/interfaces
  • @graphprotocol/toolshed
  • @graphprotocol/address-book

Existing 2FA / publish-token settings can stay; trusted publishing is additive.

Testing

Local validation with act was attempted but doesn't exercise the meaningful steps (no real OIDC token, npm self-upgrade breaks under act's tool cache). Plan post-merge:

  • Run workflow with package=toolshed, dry_run=true from the Actions tab — expect setup → npm upgrade → pnpm publish --dry-run to succeed, no tag pushed.
  • If green, run again with dry_run=false for a real publish of one package.
  • Verify the <pkg>@<version> tag lands on the repo and the published tarball shows a provenance badge on npmjs.com.
  • Repeat for the remaining packages as they're cut.

Consolidates publish.yml improvements (address-book choice, Read package
info, Tag release) from reo-deployment branches plus new interfaces and
toolshed package choices and a dry_run boolean input so auth/packaging
can be verified without burning a version.
Replace GRAPHPROTOCOL_NPM_TOKEN with GitHub OIDC (id-token: write) and
pnpm --provenance so the workflow mints a short-lived credential and
attaches a SLSA build attestation. Each target package needs its own
Trusted Publisher entry on npmjs.com (owner: graphprotocol, repo:
contracts, workflow: publish.yml); verify per-package via a dry_run
dispatch before a real publish.

Pattern follows graphprotocol/graph-node#6460. contents: write is
retained so the existing Tag release step can push the annotated tag.
pnpm publish delegates registry auth to the underlying npm CLI, which
needs to be >= 11.5.1 to exchange the GitHub OIDC token for an npm
publish credential. The shared setup action brings Node 22 which ships
an older npm; install the latest npm globally in the publish job
before pnpm publish runs.

Pattern follows eslint/config-inspector#174.
The repo's root package.json declares pnpm@10.28.0 as the
packageManager, but the shared setup action's corepack prepare step
pinned the older 10.17.0. Resolve the drift by matching the declared
version. Minor-version bump within pnpm 10.x; affects lint, build-test,
verifydeployed, and publish workflows that share this setup.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the manual publish workflow from an npm token (GRAPHPROTOCOL_NPM_TOKEN) to npm OIDC trusted publishing via GitHub Actions, adding provenance and optional dry-run behavior for safer releases.

Changes:

  • Switch publishing auth from a registry token to GitHub OIDC, enabling --provenance.
  • Add dry_run input and expand the package selection list in the publish workflow.
  • Sync the composite setup action’s Corepack-activated pnpm version with the repo’s packageManager.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/publish.yml Updates workflow_dispatch inputs, adds OIDC permissions, upgrades npm for OIDC publish, adds provenance + optional dry-run, and pushes a <pkg>@<version> git tag on real publishes.
.github/actions/setup/action.yml Bumps Corepack pnpm activation version to match root packageManager.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml
Reproducibility: pinning avoids surprise behavior changes or Node engine
bumps from a future npm "latest". Bump the pin intentionally; only
constraint is npm >= 11.5.1 for OIDC trusted publishing.
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.55%. Comparing base (d348b77) to head (49e5889).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #1324    +/-   ##
========================================
  Coverage   88.55%   88.55%            
========================================
  Files          75       75            
  Lines        4615     4615            
  Branches      981      823   -158     
========================================
  Hits         4087     4087            
  Misses        507      507            
  Partials       21       21            
Flag Coverage Δ
unittests 88.55% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

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