Skip to content

ci(publish): add id-token: write to reusable workflow jobs - #371

Merged
codewizdave merged 1 commit into
mainfrom
fix/id-token-permission
Aug 3, 2026
Merged

ci(publish): add id-token: write to reusable workflow jobs#371
codewizdave merged 1 commit into
mainfrom
fix/id-token-permission

Conversation

@martyy-code

Copy link
Copy Markdown
Contributor

Summary

Adds id-token: write to the permissions block of the single job in each of the three reusable publish workflows. Required so npm Trusted Publishing can generate a Sigstore-signed provenance attestation.

Why

GitHub Actions does not propagate permissions from a calling workflow to a called reusable workflow. As the GitHub docs put it:

permissions can only be maintained or reduced — not elevated — throughout the chain.

The publish.yml entrypoint declares id-token: write on each caller job, but the OIDC token is minted in the context of the called workflow's job. The previous permission block on the reusable job (contents: read only) was insufficient — npm's OIDC exchange succeeded (Trusted Publisher validated) but npm refused to emit the provenance attestation because the OIDC context did not carry the id-token: write scope.

Observed on the dummy e2e test (PR #370):

EUSAGE Provenance generation in GitHub Actions requires
"write" access to the "id-token" permission

_publish-canary.yml reached the publish step, npm authenticated, then failed at provenance generation. Failures were marked on the whole workflow run, with release and hotfix skipped correctly (routing) but the canary step failed.

Changes

  • _publish-release.yml: add id-token: write to the job's permissions.
  • _publish-hotfix.yml: same.
  • _publish-canary.yml: same (plus the existing pull-requests: write and contents: read).

3 insertions, 3 deletions. Each reusable workflow now declares its own OIDC dependency.

Senior rationale

The senior pattern is: every reusable workflow declares its own dependencies. The entrypoint's id-token: write stays as a documentation hint and as a defense-in-depth measure (the entrypoint job still requires the permission even though the reusable job's permission is what matters), but the reusable workflow must not assume the caller provided it.

Removing id-token: write from the entrypoint would not change the behavior, but keeping it makes the chain self-documenting: a reader of publish.yml can see at a glance that OIDC is required.

Test plan

Risk

Very low. This is a permission addition (broadening). It cannot reduce functionality. The risk that was there (a publish path that fails with EUSAGE) is removed.

Rollback

Revert the merge commit. The original behavior (EUSAGE on provenance) returns.

🤖 Generated with Claude Code

GitHub Actions does not propagate permissions from a calling
workflow to a called reusable workflow. 'permissions can only
be maintained or reduced — not elevated — throughout the chain'
(GitHub docs).

The publish.yml entrypoint declares 'id-token: write' on each
caller job, but the OIDC token is minted in the context of the
called workflow's job — which did not declare id-token: write.
This caused npm to fail with:

  EUSAGE Provenance generation in GitHub Actions requires
  "write" access to the "id-token" permission

Observed on the dummy e2e test (PR #370): _publish-canary.yml
reached the 'Publish snapshot to canary tag' step, npm
authenticated via OIDC successfully, then npm refused to
generate the provenance attestation because the OIDC context did
not carry the id-token write scope.

Fix: declare 'id-token: write' explicitly in the permissions
block of the single job inside each reusable workflow:
- _publish-release.yml
- _publish-hotfix.yml
- _publish-canary.yml

This is the senior pattern: every reusable workflow declares
its own dependencies. The entrypoint's id-token: write stays
as documentation but is not relied upon for propagation.
@codewizdave
codewizdave merged commit 10bbb04 into main Aug 3, 2026
4 checks passed
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