Skip to content

Commit b06d9a3

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-sdk-js in parallel commits.
1 parent b35a716 commit b06d9a3

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

scripts/publish.mts

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

256-
// Add provenance by default (works with trusted publishers).
257-
if (!dryRun) {
256+
// Add provenance attestation in CI only. `npm publish --provenance`
257+
// requires the GitHub Actions OIDC id-token endpoint; running locally
258+
// fails with "Provenance generation in GitHub Actions requires
259+
// 'id-token: write' permission". Gated so local non-dry-run publishes
260+
// (emergency cases) still work.
261+
if (!dryRun && process.env['GITHUB_ACTIONS'] === 'true') {
258262
publishArgs.push('--provenance')
259263
}
260264

@@ -396,7 +400,7 @@ async function main(): Promise<void> {
396400

397401
// Show help if requested.
398402
if (values.help) {
399-
console.log('\nUsage: pnpm publish [options]')
403+
console.log('\nUsage: pnpm release [options]')
400404
console.log('\nOptions:')
401405
console.log(' --help Show this help message')
402406
console.log(' --dry-run Perform a dry-run without publishing')
@@ -407,10 +411,10 @@ async function main(): Promise<void> {
407411
console.log(' --otp <otp> npm one-time password')
408412
console.log('\nExamples:')
409413
console.log(
410-
' pnpm publish # Validate artifacts and publish',
414+
' pnpm release # Validate artifacts and publish',
411415
)
412-
console.log(' pnpm publish --dry-run # Dry-run to test')
413-
console.log(' pnpm publish --otp 123456 # Publish with OTP')
416+
console.log(' pnpm release --dry-run # Dry-run to test')
417+
console.log(' pnpm release --otp 123456 # Publish with OTP')
414418
process.exitCode = 0
415419
return
416420
}

0 commit comments

Comments
 (0)