Skip to content

Prepare npm trusted publishing (OIDC) - #305

Merged
agorischek merged 4 commits into
mainfrom
agorischek-friendly-parakeet
Dec 5, 2026
Merged

agorischek merged 4 commits into
mainfrom
agorischek-friendly-parakeet

Conversation

@agorischek

@agorischek agorischek commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Prepares @githubnext/projections-sdk for npm trusted publishing (OIDC). Nothing turns on: NPM_PUBLISHING stays unset and there's no npm environment, so the workflow still only logs a notice. npm publishing still awaits security approval.

  • One workflow publishes. npm's trusted publishing checks the workflow that started the run: with workflow_call, that's the caller (release.yml), not publish-npm.yml (npm docs, troubleshooting). Registering both would also be fragile: unvalidated trusted-publisher configurations expire after 48 hours (changelog), so a release.yml registration could only be validated by a release within two days. So when the release calls publish-npm.yml, a new dispatch job runs gh workflow run publish-npm.yml --ref <tag> (GITHUB_TOKEN can start workflow_dispatch runs), and the publish job runs only for workflow_dispatch. Automatic and manual publishes are then both publish-npm.yml, the one workflow npm needs to trust. The release's call gets actions: write (dist-workspace.toml, release.yml regenerated with dist 0.34.0).
  • Token check stays up front. With NPM_PUBLISHING=token, a missing NPM_TOKEN still fails before the already-published check, as on main; that step sees only whether the secret is set, not the secret.
  • No token in trusted mode. setup-node no longer gets registry-url, so it writes no .npmrc and exports no placeholder NODE_AUTH_TOKEN. Publishing is split into a trusted step (no token env) and a token step that alone sees NPM_TOKEN, writing a temporary userconfig that references ${NODE_AUTH_TOKEN} (npm expands it; the token isn't written to disk).
  • npm --ignore-scripts publish … --provenance. packages/sdk has no prepack/prepublishOnly/prepare scripts and the job builds it beforehand, so nothing is skipped.
  • npm version guard. .node-version (26.12.1) ships npm 11.20.0, so no upgrade is needed; the job now fails clearly if npm is older than 11.5.1 instead of just printing the version.
  • Self topology recognises npm <options> publish (including --workspace sdk, -w sdk or --workspace=sdk before publish; only options known to take a value consume the next word), so the release-channel extractor still sees the npm publish once it's turned on.
  • packages/cli/test/release.test.mjs expects the npm post-announce job's new actions: write.
  • docs/maintainers/npm-publishing.md describes the stub-first setup (placeholder publish with --access public, the publishing-access 2FA setting, the npm environment, the trusted publisher's exact fields including allowing direct npm publish, NPM_PUBLISHING=trusted, then running Publish npm package within 48 hours), and why one workflow publishes.

Evidence

Rebased onto main after #394 renamed the package to @githubnext/projections-sdk; the workflow, dist-workspace.toml and the npm publishing guide use the new name.

  • node --test packages/cli/test/release.test.mjs: 7 pass (after the rebase)
  • node --test .github/projections/self-topology/releases.test.mjs: 5 pass, now covering space-separated option values (--workspace sdk, -w sdk, --registry <url>) and not reading npm --silent -w sdk run publish as a publish
  • node tools/scripts/dist.mjs --check (dist 0.34.0): pass; regenerating release.yml changes nothing
  • npm run format:check (oxfmt): pass
  • Actions lockfile: no uses: added or changed; actions/checkout and actions/setup-node are in actions.lock (gh actions-lock --verify not run locally)

Before the rebase:

  • npm run tools -- check --fast: pass

  • npm run tools -- check --affected: pass (comparators after tools build packages/comparators/runtime/js)

  • npm run tools -- test --affected: pass (no workspace changed)

  • node --test .github/projections/self-topology/releases.test.mjs: 5 pass, including a new case for options (and --workspace=) before publish

  • node --test packages/cli/test/release.test.mjs: 7 pass

  • node tools/scripts/dist.mjs --check (dist 0.34.0): pass

  • actionlint 1.7.12 with shellcheck on publish-npm.yml: no findings

  • Not run: the workflow itself (it's inert until configured, and publishing awaits approval).

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate).

  • Fixes include a regression test.

  • A changelog fragment at changelog.d/<this PR's number>.md describes what
    users will notice, or the PR has the no changelog label (see
    changelog.d/README.md).

  • No credentials, private source or machine-specific paths are included.

@agorischek agorischek added the no changelog Users won't notice this change: no changelog.d/ fragment needed (changelog.d/README.md) label Dec 4, 2026
@agorischek
agorischek requested a balanced review from Copilot December 4, 2026 04:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The release parser drops workspace options placed before publish, causing valid npm publish commands to lose their release channel.

1 open issue
What changed in this PR

Prepares npm trusted publishing while keeping publication disabled until approved and configured.

Changes:

  • Dispatches npm publishing through one workflow with the required permissions.
  • Separates trusted and token authentication, disables publish scripts, and checks npm compatibility.
  • Documents setup and extends release-channel detection with regression coverage.
File Description
docs/​maintainers/​npm-publishing.md Documents trusted publishing setup and workflow design.
dist-workspace.toml Grants npm workflow dispatch permission.
.github/​workflows/​release.yml Reflects generated permission changes.
.github/​workflows/​publish-npm.yml Adds dispatch and separate authentication paths.
.github/​projections/​self-topology/​releases.test.mjs Tests npm options before publish.
.github/​projections/​self-topology/​releases.mjs Recognizes leading npm options.

Review effort: Balanced

@agorischek
agorischek marked this pull request as ready for review December 4, 2026 20:45
@agorischek
agorischek force-pushed the agorischek-friendly-parakeet branch from bd64501 to c456951 Compare December 4, 2026 20:45
@agorischek
agorischek requested a balanced review from Copilot December 4, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The leading-option pattern misses space-separated option values, causing valid npm publish commands to silently lose their release channel.

1 open issue
1 resolved since last review

Review effort: Balanced

agorischek and others added 3 commits December 5, 2026 03:15
Every npm publish now runs as publish-npm.yml: when the release calls it,
it dispatches itself at the release tag, because npm's trusted publishing
checks the workflow that started the run (release.yml under workflow_call).
Trusted publishing sets no NODE_AUTH_TOKEN and setup-node writes no .npmrc;
token publishing configures its own. Publishing uses
npm --ignore-scripts publish and checks npm is 11.5.1 or later. The npm
publishing guide describes the stub-first setup.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
… test

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@agorischek
agorischek force-pushed the agorischek-friendly-parakeet branch from c456951 to de4678c Compare December 5, 2026 03:15
…blish

npm --workspace sdk publish, npm -w sdk publish and npm --registry <url> publish now count as npm publishes. Only options known to take a value consume the next word, so npm --silent run publish isn't one.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit e6073f2 into main Dec 5, 2026
8 checks passed
@agorischek
agorischek deleted the agorischek-friendly-parakeet branch December 5, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog Users won't notice this change: no changelog.d/ fragment needed (changelog.d/README.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants