Skip to content

ci(cd): migrate npm publish to trusted publishing before the Jan 2027 bypass-2FA restriction #256

Description

@smileygames

目的

.github/workflows/cd.yml の npm publish を、Bypass 2FA 付き granular access token から Trusted Publishing(OIDC) に移行する。

期限がある。2027年1月に、Bypass 2FA トークンによる direct publishing が npm 側で制限される。

観測(2026-09-09)

v0.11.0 の CD が npm-publish で落ちた。

npm error code E404
npm error 404 Not Found - PUT https://registry.npmjs.org/github-rag-mcp
npm error 404  The requested resource 'github-rag-mcp@0.11.0' could not be found
          or you do not have permission to access it.
  • build-mcpb / attach-mcpb は success。壊れているのは npm 配布経路のみ
  • npm view github-rag-mcp version = 0.10.2。パッケージは存在する。よって PUT に対する 404 は「名前未取得」ではなく資格情報側
  • 素の再実行でも逐語同一のエラー。一時障害ではない
  • 当座の対処は token 差し替え(NPM_TOKEN secret)。本 issue はその恒久側

期限の根拠

npm のトークン作成画面に出る警告 literal:

npm tokens that bypass 2FA are being restricted — account changes (Aug 2026) and direct publishing (Jan 2027).

docs 側:

"At the moment, bypass-2FA tokens can still be used for direct publishing. For CI/CD publishing, consider adopting trusted publishing instead."

出典: https://docs.npmjs.com/about-access-tokens

制約

  • トークン期限を短くすることは対策にならない。 2027年1月以降は、トークンが有効かどうかに関わらず direct publishing が落ちる。短い期限が与えるのは、更新のため npm の画面を開く機会が挟まること(移行し忘れへの人間側チェックポイント)だけであり、制限そのものへの防御ではない
  • 現行の cd.yml には permissions: id-token: write が無い。移行時に追加が必要
  • npm 側でリポジトリを信頼発行元として登録する操作は、パッケージ所有者(人間)の操作。AI 側では完結しない

target files

  • .github/workflows/cd.ymlnpm-publish job に permissions: id-token: write を追加、NODE_AUTH_TOKEN 経路を除去
  • npm 側の Trusted Publisher 登録(リポジトリ外の操作。人間ゲート)

未検証の前提(forming → ready の条件)

  • Trusted Publishing が要求する npm CLI の最低バージョン、および actions/setup-node 側の設定
  • 移行後に NPM_TOKEN secret を削除してよいか(他の workflow が参照していないかの確認)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement新機能・改善要望forming本文を再構築しながら要求を整えている状態

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions