ci(publish): add id-token: write to reusable workflow jobs - #371
Merged
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
id-token: writeto 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:
The
publish.ymlentrypoint declaresid-token: writeon 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: readonly) 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 theid-token: writescope.Observed on the dummy e2e test (PR #370):
_publish-canary.ymlreached the publish step, npm authenticated, then failed at provenance generation. Failures were marked on the whole workflow run, withreleaseandhotfixskipped correctly (routing) but the canary step failed.Changes
_publish-release.yml: addid-token: writeto the job'spermissions._publish-hotfix.yml: same._publish-canary.yml: same (plus the existingpull-requests: writeandcontents: 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: writestays 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: writefrom the entrypoint would not change the behavior, but keeping it makes the chain self-documenting: a reader ofpublish.ymlcan see at a glance that OIDC is required.Test plan
pnpm turbo type-checkpasses.pnpm turbo lintpasses.@canarydist-tag with provenance.changeset-version.ymlafter merging docs(fp): dummy e2e release test (1.0.1 -> 1.0.2) #370 publishes@latestwith provenance.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