Skip to content

Commit 07c19ef

Browse files
committed
fix(publish): gate --provenance on GITHUB_ACTIONS to unbreak local runs
`npm publish --provenance` requires the GitHub Actions OIDC id-token endpoint — running the script locally (non-dry-run) fails with "Provenance generation in GitHub Actions requires 'id-token: write' permission". Guarded the flag behind `process.env.GITHUB_ACTIONS === 'true'` so local emergency publishes still work. CI runs unchanged. Same fix landed in stuie + socket-registry + socket-packageurl-js in parallel commits.
1 parent 8a5f17f commit 07c19ef

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

scripts/publish.mts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,12 @@ async function publishPackage(options: PublishOptions = {}): Promise<boolean> {
270270
// Prepare publish args.
271271
const publishArgs = ['publish', '--access', access, '--tag', tag]
272272

273-
// Add provenance by default (works with trusted publishers).
274-
if (!dryRun) {
273+
// Add provenance attestation in CI only. `npm publish --provenance`
274+
// requires the GitHub Actions OIDC id-token endpoint; running locally
275+
// fails with "Provenance generation in GitHub Actions requires
276+
// 'id-token: write' permission". Gated so local non-dry-run publishes
277+
// (emergency cases) still work.
278+
if (!dryRun && process.env['GITHUB_ACTIONS'] === 'true') {
275279
publishArgs.push('--provenance')
276280
}
277281

0 commit comments

Comments
 (0)