Skip to content

Commit 8c8d7b7

Browse files
just-be-devclaude
andauthored
Fix npm publishing with OIDC provenance support (#187)
* Fix npm package publishing with OIDC provenance support - Use npm publish with --provenance flag for OIDC attestations instead of bun publish - Package with bun pm pack, then publish using npm via bunx for provenance support - Add npm authentication setup step to workflow using NPM_TOKEN secret - Requires NPM_TOKEN secret to be set in GitHub repository for authentication Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * Remove npm authentication setup step from workflow Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 47e3e74 commit 8c8d7b7

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

scripts/publish-package.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,19 @@ async function publishPackage(packageName: string, packagePath: string): Promise
7878

7979
console.log(` Publishing...`);
8080

81-
// Publish to npm (tolerate-republish provides safety net for edge cases)
82-
await $`cd ${packagePath} && bun publish --access public --tolerate-republish`;
81+
// Package with bun, then publish with npm to get provenance support
82+
// npm's --provenance flag enables OIDC-based attestations
83+
await $`cd ${packagePath} && bun pm pack`;
84+
85+
// Find the packed tarball (bun pm pack creates a .tgz file)
86+
const files = await Array.fromAsync(new Bun.Glob("*.tgz").scan({ cwd: packagePath }));
87+
if (files.length === 0) {
88+
throw new Error("No tarball found after packing");
89+
}
90+
const tarball = files[0];
91+
92+
// Publish using npm with provenance
93+
await $`cd ${packagePath} && bunx npm publish ${tarball} --access public --provenance`;
8394

8495
// Create GitHub release (this creates the tag and release atomically)
8596
const tag = `${packageName}@${localVersion}`;

0 commit comments

Comments
 (0)