Skip to content

ci(release): drop registry-url to unblock OIDC npm publish - #977

Merged
kwit75 merged 1 commit into
mainfrom
dmitrii/oidc-npm-publish-no-registry-url
May 23, 2026
Merged

kwit75 merged 1 commit into
mainfrom
dmitrii/oidc-npm-publish-no-registry-url

Conversation

@kwit75

@kwit75 kwit75 commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #976. That PR enabled OIDC trusted publishing for the TS client but the publish still failed because actions/setup-node@v4 was auto-injecting NODE_AUTH_TOKEN into the publish step's env, preempting the OIDC flow.

Root cause

setup-node's auth setup runs whenever registry-url is set. It:

  1. Writes a .npmrc with _authToken=${NODE_AUTH_TOKEN}
  2. Exports NODE_AUTH_TOKEN to the job env, sourced from its with.token input
  3. The token input defaults to ${{ github.token }} — the workflow's auto-injected GitHub token

With NODE_AUTH_TOKEN in env, npm CLI uses static-token auth (not the npm-recommended OIDC flow). The GITHUB_TOKEN isn't a valid npm credential, so the PUT returns 404 with the "permission denied" wording.

Fix

Remove registry-url from the setup-node step. Then setup-node skips auth setup entirely — no .npmrc, no NODE_AUTH_TOKEN injection. npm CLI defaults to https://registry.npmjs.org/ (npm's built-in default for unscoped packages like rocketride) and, finding no static token + seeing --provenance, performs the OIDC trusted-publisher exchange against the config already set up on npmjs.com (repo rocketride-org/rocketride-server, workflow _release.yaml, environment release).

Also logs npm --version after the explicit upgrade so future debugging can confirm npm >= 11.5.1 is in effect.

Test plan

  • CI green (Build / Ubuntu 22.04, gitleaks)
  • After merge, release.yaml fires from main. TS Client step:
    • Logs npm: 11.x.x after the explicit upgrade
    • Auth path is OIDC (no NODE_AUTH_TOKEN in env)
    • PUT to registry.npmjs.org/rocketride succeeds with provenance attestation
  • Delete the NPM_TOKEN repo secret after confirmation (no longer used)

PR #976 switched the TS client publish to OIDC trusted publishing but
the publish still 404'd with a "permission" error. Job log showed
NODE_AUTH_TOKEN was still being injected into the publish step's env
despite being removed from the workflow `env:` block.

Root cause: actions/setup-node@v4 auto-exports NODE_AUTH_TOKEN whenever
`registry-url` is set, sourcing the value from its `token` input which
defaults to ${{ github.token }} (the workflow's auto-injected
GITHUB_TOKEN). With NODE_AUTH_TOKEN present, npm CLI uses token auth
and never attempts the OIDC trusted-publisher exchange — but the
GITHUB_TOKEN isn't a valid npm credential, so the PUT 404s.

Removing `registry-url` stops setup-node from writing .npmrc and from
exporting NODE_AUTH_TOKEN. Default registry stays at npmjs.org (npm's
built-in default), which is correct for the unscoped `rocketride`
package. With no static token in the env and `--provenance` set,
npm CLI auto-exchanges the GitHub OIDC token against the trusted
publisher config on npmjs.com.

Also logs `npm --version` after the explicit upgrade so future
debugging can confirm npm >= 11.5.1 is actually in use.
@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (5)
  • [bot]
  • renovate
  • dependabot
  • release
  • chore(release)

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 718d0dc7-a4cb-4dd2-9bb0-41161a15e6bb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dmitrii/oidc-npm-publish-no-registry-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the ci/cd CI/CD and build system label May 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No description provided.

@kwit75
kwit75 requested a review from anandray May 23, 2026 01:10

@anandray anandray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Correct root cause — setup-node@v4 auto-injects NODE_AUTH_TOKEN whenever registry-url is set, which silently kept #976's OIDC switch from firing. Dropping registry-url is the minimal fix; npm defaults to registry.npmjs.org anyway for unscoped packages.

@kwit75
kwit75 merged commit c719ec2 into main May 23, 2026
19 checks passed
@kwit75
kwit75 deleted the dmitrii/oidc-npm-publish-no-registry-url branch May 23, 2026 01:29
kwit75 added a commit that referenced this pull request May 23, 2026
PR #976 + #977 switched to OIDC trusted publishing but the TS publish
step is still failing — now with ENEEDAUTH (no auth found), which means
npm 11.15 is not engaging the OIDC trusted publisher exchange even
though id-token: write is set at the job level and the trusted
publisher is configured on npmjs.com.

This change adds diagnostic logging to surface what npm sees:
  - npm version (confirms >= 11.5.1)
  - CI / GITHUB_ACTIONS env vars
  - ACTIONS_ID_TOKEN_REQUEST_URL / _TOKEN presence (OIDC env vars)
  - NODE_AUTH_TOKEN presence (should be UNSET)
  - npm config get registry (which registry npm targets)
  - existence of .npmrc files in RUNNER_TEMP and HOME

And runs npm publish with --loglevel verbose so the auth-flow internals
are visible in the job log.

Diagnostic-only — does not change auth setup. Once we see what npm is
doing, we can fix it properly in a follow-up.

Co-authored-by: Dmitrii Kataraev <dmitrii.kataraev@rocketride.ai>
kwit75 added a commit that referenced this pull request May 27, 2026
Reconciles main (which had #976/#977/#978 OIDC publish fixes never
back-merged to develop) with stage (= develop + version bump).

Conflict resolution: take stage's content (= develop's truth) for all
divergent files, EXCEPT .github/workflows/{_release,release}.yaml where
main's OIDC publishing config is preserved (otherwise next release would
revert to NODE_AUTH_TOKEN flow).

After this merge, stage contains: today's PR set + version bump 3.2.1/1.1.1 +
OIDC publish config. Ready to fire release.yaml on push to main.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd CI/CD and build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants