Skip to content

fix(npm): correct OIDC diagnostic + document trusted-publishing limitation - #103

Merged
jleni merged 1 commit into
mainfrom
fix/npm-oidc-diagnostic-and-docs
Jun 20, 2026
Merged

fix(npm): correct OIDC diagnostic + document trusted-publishing limitation#103
jleni merged 1 commit into
mainfrom
fix/npm-oidc-diagnostic-and-docs

Conversation

@jleni

@jleni jleni commented Jun 20, 2026

Copy link
Copy Markdown
Member

Context

@zondax/cli releases kept failing with npm error E404 ... '@zondax/cli@x.y.z' is not in this registry when publishing through _publish-npm.yaml, despite a correctly-configured npm Trusted Publisher. This PR fixes the misleading diagnostic that sent us down the wrong path, and documents the underlying limitation (now verified).

What this PR changes (safe, non-behavioral)

  1. Fix the OIDC diagnostic. Debug OIDC environment read ${{ env.ACTIONS_ID_TOKEN_REQUEST_URL }} / _TOKEN. The env context only exposes env:-declared vars, not runner-injected OIDC vars — so it always printed is set: false, even when the token was present. We chased a phantom "no OIDC token" for hours because of this. Now read from the shell ([ -n "$ACTIONS_ID_TOKEN_REQUEST_URL" ]).
  2. Print github.job_workflow_ref (the claim npm actually validates) instead of the empty github.job_workflow_sha.
  3. Header note documenting that OIDC trusted publishing can't work through this reusable workflow.

The real finding (verified)

npm trusted publishing validates the OIDC job_workflow_ref — the workflow file that runs npm publish. For a reusable workflow that's this file (zondax/_workflows/.github/workflows/_publish-npm.yaml), not the caller. A package's Trusted Publisher can only name one repo + workflow (e.g. Zondax/cli · publish-npm.yaml), so a publish performed here can never match it → E404.

Proof: @zondax/cli failed every publish through this reusable workflow (v7 and v10), then published successfully (1.14.1) the moment its npm publish ran in its own repo workflow (Zondax/cli/.github/workflows/publish-npm.yaml) with id-token: write.

OIDC vs token — strategy options (org decision)

Option How Trade-off
A. Self-contained per-package publish (recommended) Each package runs npm publish in its own workflow with id-token: write; keep OIDC trusted publishing (no tokens). Zondax/cli already does this. Matches the "no tokens" intent; a few lines of YAML per repo (can be templated). Reusable workflow no longer used for npm publish.
B. Reusable workflow + token Add an npm_token secret input here and auth with NODE_AUTH_TOKEN. Keeps one shared workflow, but reintroduces long-lived tokens per package — the thing trusted publishing removed.

Recommendation: A. I'm happy to add a documented self-contained publish-npm.yaml template (mirroring cli's) and either deprecate npm publishing from this reusable workflow or gate it behind a token input — your call.

🤖 Generated with Claude Code

…ation

The 'Debug OIDC environment' step read ACTIONS_ID_TOKEN_REQUEST_URL/TOKEN via
${{ env.* }}, which never sees runner-injected vars and always printed 'false'
— a misleading red herring while debugging publish failures. Read them from the
shell instead, and print github.job_workflow_ref (the claim npm actually checks)
rather than the empty job_workflow_sha.

Also document, in the header, that npm OIDC trusted publishing cannot work
through a reusable workflow (npm matches job_workflow_ref = this file, which a
per-package trusted publisher can't name) — so packages must publish in their
own workflow. Verified end-to-end with @zondax/cli.
@jleni
jleni merged commit 05578b6 into main Jun 20, 2026
1 check passed
@jleni
jleni deleted the fix/npm-oidc-diagnostic-and-docs branch June 20, 2026 16:11
jleni added a commit that referenced this pull request Jun 20, 2026
…able workflow) (#104)

* docs(npm): correct trusted-publishing guidance — it DOES work via reusable workflow

#103 wrongly stated OIDC trusted publishing can't work through this reusable
workflow. It does: many @Zondax packages (casper/filecoin/substrate/...) publish
via it with OIDC and no token. The real requirement is that the package's npm
Trusted Publisher must use Workflow filename '_publish-npm.yaml' (this file =
the job_workflow_ref npm matches), NOT the caller's workflow filename.

@zondax/cli failed only because its Trusted Publisher named 'publish-npm.yaml'
(its caller). Correct the header to give the right configuration.

* docs(npm): align trusted-publisher guidance with npm's documented behavior

Per npm docs, for reusable/workflow_call publishing the Trusted Publisher's
Workflow filename must be the CALLER's workflow (not this file), and npm flags
this path as finicky ('checks the calling workflow's name ... can cause
configuration mismatches'). Recommend self-contained publish as the reliable
fallback. Corrects my earlier '_publish-npm.yaml' guidance.
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.

1 participant