Skip to content

fix(release): publish bun-packed tarball with npm (reliable CI auth) - #27

Merged
otomatty merged 1 commit into
mainfrom
claude/npm-package-setup-5qxg1o
Jun 23, 2026
Merged

otomatty merged 1 commit into
mainfrom
claude/npm-package-setup-5qxg1o

Conversation

@otomatty

Copy link
Copy Markdown
Owner

背景

PR #26(version packages)マージ後の Release ワークフローの publish ジョブが失敗しました:

error: missing authentication (run `bunx npm login`)
error: Command failed: bun publish

NPM_TOKEN シークレットは正しく渡っており(ログ上 NPM_TOKEN: ***)、~/.npmrc も書き込み済みでしたが、bun publish は CI で ~/.npmrc の認証トークンを読み取れない既知のバグがあります(oven-sh/bun#24124)。同じ .npmrc で npm publish は成功します。

修正

publish を 2ツール構成に変更:

  1. bun pm pack で tarball を生成 — bun が workspace:* を実バージョンに解決(npm publish を直接使うと workspace:* が残り EUNSUPPORTEDPROTOCOL になる問題を回避)
  2. npm publish <tarball> --access public でアップロード — npm は ~/.npmrc のトークンを確実に読む。tarball の manifest は解決済みなので npm が workspace: に遭遇することはない

冪等性・workspace: 混入ガード・New tag: マーカー出力は変更なし。

検証

ローカルで確認済み:

  • bun-packed tarball の依存が解決済み(@otomatty/core → "@otomatty/tokens": "0.0.0"、workspace: なし)
  • npm publish <tarball> --access public --dry-run が tarball を受理(+ @otomatty/core@0.0.0、public access)
  • lint クリーン

マージ後

このPRをマージ → Release ワークフローの失敗した publish を再実行(または PR #26 を再マージ)すれば、@otomatty/* v0.1.0 が npm に公開されます。

🤖 Generated with Claude Code


Generated by Claude Code

`bun publish` ignores ~/.npmrc in CI and fails with "missing authentication"
(oven-sh/bun#24124), so the publish job errored despite a valid NPM_TOKEN.

Keep bun for packing — it resolves `workspace:*` to concrete versions — but
upload the resulting tarball with `npm publish <tarball> --access public`, which
reads the token from ~/.npmrc reliably. The packed manifest is already resolved,
so npm never encounters a workspace: range. Idempotency, the workspace-range
guard, and the `New tag:` markers are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AwrAKRmfpXZnTp7M57V6u9
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

scripts/publish.ts の公開手順を変更した。従来は bun publish を直接呼び出していたが、bun pm pack で workspace:* 参照を解決した tarball を生成し、その tarball を npm publish <tarball> --access public でアップロードする2段階方式へ移行した。検証専用だった assertNoWorkspaceRanges 関数を廃止し、tarball 生成・検証・クリーンアップを packResolved(dir, name) に統合した。公開ループでは packResolved が返す tarball を try ブロックで npm publish に渡し、finally で一時ディレクトリを削除する構造になっている。

Poem

🐇 もう bun publish じゃないのさ、
pm pack で tgz をくるっとまとめ、
workspace: が残ってないかちゃんと確かめ、
npm publish にそっと手渡す。
finally でお片付け、完璧だぴょん ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR タイトル「fix(release): publish bun-packed tarball with npm (reliable CI auth)」は、変更の主要な内容である、bun pm pack で tarball を生成して npm publish で公開する方式への変更を明確に要約しており、CI 環境での認証の信頼性改善という背景も簡潔に反映している。
Description check ✅ Passed PR の説明は変更の背景(bun publish の CI 認証バグ)、修正方法(bun pm pack と npm publish の組み合わせ)、検証内容、マージ後の影響を具体的に記載しており、変更内容と密接に関連している。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/npm-package-setup-5qxg1o

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5daa333057

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/publish.ts
const { tarball, cleanup } = packResolved(dir, name);
try {
console.log(`▲ publishing ${name}@${version}`);
execFileSync('npm', ['publish', tarball, '--access', 'public'], { stdio: 'inherit' });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject stale workspace versions before publishing

When this path publishes the tarball produced by bun pm pack, packages with workspace deps inherit the checked-in bun.lock workspace versions, which are still 0.0.0 even though the package manifests are 0.1.0; I confirmed by packing packages/core, whose tarball manifest contains "@otomatty/tokens": "0.0.0". Because this line now uploads that tarball directly, @otomatty/core@0.1.0 and the React packages will depend on non-existent/old @otomatty/*@0.0.0 versions, so consumer installs can fail even though the workspace: string guard passes.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/publish.ts (1)

96-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

pack失敗時の stderr を握り潰さない方が、CIでの原因調査が容易になります。

npm publish 側は stdio: 'inherit' ですが、こちらは stdio: 'ignore' のため bun pm pack が失敗しても標準エラー出力が表示されず、execFileSync の汎用エラーしか残りません。少なくとも stderr は親プロセスへ流すことを検討してください。

♻️ stderr を表示する変更案
     execFileSync('bun', ['pm', 'pack', '--quiet', '--destination', out], {
       cwd: dir,
-      stdio: 'ignore',
+      stdio: ['ignore', 'ignore', 'inherit'],
     });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/publish.ts` around lines 96 - 99, The execFileSync call for the bun
pm pack command is suppressing all output with stdio: 'ignore', which makes it
difficult to diagnose failures in CI environments. To improve debuggability and
align with the npm publish call above which uses stdio: 'inherit', change the
stdio option in the execFileSync call for bun pm pack from 'ignore' to 'inherit'
so that stderr output from the pack operation is visible to the parent process.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/publish.ts`:
- Around line 96-99: The execFileSync call for the bun pm pack command is
suppressing all output with stdio: 'ignore', which makes it difficult to
diagnose failures in CI environments. To improve debuggability and align with
the npm publish call above which uses stdio: 'inherit', change the stdio option
in the execFileSync call for bun pm pack from 'ignore' to 'inherit' so that
stderr output from the pack operation is visible to the parent process.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94f44680-5384-48cd-9466-00b13d93e47c

📥 Commits

Reviewing files that changed from the base of the PR and between f62d36e and 5daa333.

📒 Files selected for processing (1)
  • scripts/publish.ts

@otomatty
otomatty merged commit 6ba8d7e into main Jun 23, 2026
4 checks passed
@otomatty
otomatty deleted the claude/npm-package-setup-5qxg1o branch June 23, 2026 23:38
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