Skip to content

ci(runtime): publish with npm trusted publishing - #780

Merged
winterfx merged 1 commit into
mainfrom
ci/runtime-trusted-publishing
Oct 14, 2026
Merged

winterfx merged 1 commit into
mainfrom
ci/runtime-trusted-publishing

Conversation

@winterfx

Copy link
Copy Markdown
Collaborator

Summary

Publish the two runtime npm packages through npm trusted publishing (GitHub OIDC) instead of a long-lived registry token.

runtime-v0.12.0 failed in run #38508434777: Verify runtime package versions and Check npm token both passed (so the secret is non-empty), then Publish returned

npm error code E404
npm error 404 Not Found - PUT https://registry.npmjs.org/@chaitin-ai%2fagent-compose-runtime - Not found

A non-empty token that the registry rejects produces exactly this 404 for a scoped package, and npm is now restricting bypass-2FA tokens for direct publishing. Trusted publishing removes the token from the path entirely.

Changes:

  • remove NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} and the Check npm token step from both publish jobs;
  • use Node 24 in both publish jobs: trusted publishing requires npm >= 11.5.1, and Node 22 bundles npm 10.9.x, which predates it;
  • add a Check trusted publishing preconditions step that verifies the npm version and that ACTIONS_ID_TOKEN_REQUEST_URL is present, so a missing id-token: write fails before the build instead of at publish time;
  • move id-token: write from the workflow level to the two publish jobs, so the verify job only gets contents: read;
  • add a Check published version step that skips npm publish when the version already exists, which keeps the workflow re-dispatchable when one package succeeds and the other fails.

Both trusted publishers are already registered on npm: @chaitin-ai/agent-compose-runtime and @chaitin-ai/agent-compose-runtime-sdk, each bound to chaitin/agent-compose + publish-runtime.yml with publish, stage publish permissions and no environment restriction.

Note for reviewers: the organization-level NPM_TOKEN secret must stay in place for now. chaitin/ModelKit's npm_publish.yml still uses it, and that workflow runs Node 18 with pnpm 8, so it cannot use OIDC without its own migration.

Testing

  • task lint, task build, and task test were not run: this change touches only a CI workflow, with no Go or TypeScript changes.
  • Workflow YAML parses correctly; jobs, permissions, and step order verified.
  • The new skip guard was checked against the live registry: both packages resolve @0.11.0 to skip and @0.12.0 to publish (0.12.0 is not published yet; the highest published version is 0.11.0).
  • The precondition version comparison rejects a simulated npm 10.9.3 as intended.
  • End-to-end validation requires a workflow_dispatch run after this merges; draft PRs skip CI and no workflow run covers this path.

Checklist

  • No documentation update is needed; publishing setup is not covered by docs/pages.
  • No tests added: the change is CI configuration only, and the behavior is not exercisable from a unit test.
  • No secrets, private endpoints, internal certificates, or local runtime state included. This change removes the workflow's dependency on secrets.NPM_TOKEN.

Both runtime packages authenticate through GitHub OIDC trusted publishing
instead of NPM_TOKEN. Run 38508434777 failed with E404 on the first
package: the secret was present, but the registry no longer accepts that
token for publishing.

Node 24 is required because trusted publishing needs npm >= 11.5.1, and a
precondition step now checks the npm version and the OIDC endpoint. The
publish jobs own `id-token: write`, and a version check skips already
published versions so a partially successful run can be re-dispatched.
@monkeyscan

monkeyscan Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

PR Title: ci(runtime): publish with npm trusted publishing

Commit: 439f772

整体评估

本次改动把 runtime 两个 npm 包的发布认证从长期 NPM_TOKEN 迁移到 npm trusted publishing(GitHub OIDC):将 id-token: write 从工作流级收敛到两个发布 job,把 Node 升到 24,并用 npm 版本与 OIDC 端点校验替换原来的 token 校验,同时新增“已发布即跳过”的幂等发布保护。整体方向正确、改动自洽,符合最小权限原则。

总结

未发现由本次改动引入的正确性、安全或数据完整性缺陷:权限收敛、版本前置校验与幂等跳过逻辑均实现正确。需留意的只是运行环境前提——npm 侧需已为这两个包配置好 trusted publisher,建议在真实发布环境完成一次端到端发布验证。

@winterfx
winterfx marked this pull request as ready for review October 14, 2026 11:06
@winterfx
winterfx merged commit 616d645 into main Oct 14, 2026
28 checks passed
@winterfx
winterfx deleted the ci/runtime-trusted-publishing branch October 14, 2026 11:12
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