Skip to content

feat(release): CI/CD publish pipeline for mcp (npm) + leadclaw (npm + ClawHub)#7

Merged
milstan merged 1 commit intomainfrom
milstan/publish-ci
Apr 21, 2026
Merged

feat(release): CI/CD publish pipeline for mcp (npm) + leadclaw (npm + ClawHub)#7
milstan merged 1 commit intomainfrom
milstan/publish-ci

Conversation

@milstan
Copy link
Copy Markdown
Contributor

@milstan milstan commented Apr 21, 2026

Summary

Tag-driven publishing for both public packages, with auth preflight and version-drift guards so a failed release always fails loud.

Tag scheme

Why it's this way

  • Preflight job runs npm whoami + npm access list packages @leadbay before either publish, so auth/scope issues surface in a clear step instead of mid-publish.
  • npm before ClawHub for leadclaw because openclaw.plugin.json#install.npmSpec resolves installs via npm — ClawHub pointing at a missing npm version would break installs.
  • ClawHub CLI pinned to clawhub@^0.9. Auth via clawhub login --token because no CLAWHUB_TOKEN env-var shortcut exists (verified against CLI source).
  • Version drift trap: leadclaw release verifies tag, package.json#version, and openclaw.plugin.json#version all agree.

Repo hygiene

  • packages/mcp/src/bin.ts: VERSION now injected at build time by tsup define from package.json, so --version and the tarball version can't drift. vitest mirrors the define.
  • Pre-existing typecheck error on bin.ts:170 (stdin data handler) fixed so prepublishOnly can gate on typecheck.
  • prepublishOnly now runs build + typecheck + test on both packages (previously just tsup on mcp, absent on leadclaw).
  • packages/leadclaw/README.md created (was missing but listed in files — would have broken npm pack).
  • CHANGELOGs for both packages seeded at 0.2.0.
  • RELEASE.md at repo root — tag-driven release runbook with failure-mode debugging.
  • ci.yml now runs typecheck and packs both tarballs on every PR, so the same "README.md missing" class of bug can't sneak back in.

One-time setup (done)

  • NPM_TOKEN repo secret — npm automation token with publish rights on @leadbay.
  • CLAWHUB_TOKEN repo secret — ClawHub publish token with rights on @leadbay.
  • @leadbay npm org (not yet verified owned; preflight will fail loud if the token can't reach it).

Test plan

  • pnpm -r build green
  • pnpm -r typecheck green
  • pnpm -r test green (19/19 mcp, 12/12 leadclaw)
  • npm pack --dry-run in both packages — tarballs include expected files, no stale references
  • node packages/mcp/dist/bin.js --version0.2.0 (proves the VERSION injection works end-to-end)
  • CI green on this PR
  • After merge: git tag mcp-v0.2.0 && git push origin mcp-v0.2.0 → workflow publishes @leadbay/mcp@0.2.0
  • Then: git tag leadclaw-v0.2.0 && git push origin leadclaw-v0.2.0 → workflow publishes @leadbay/leadclaw@0.2.0 to npm then ClawHub

🤖 Generated with Claude Code

…dbay/leadclaw (npm + ClawHub)

Tag-driven publishing with prefix-scoped tags, so each package ships
independently and never on accident:

  - mcp-v*.*.*       → publishes @leadbay/mcp to npm
  - leadclaw-v*.*.*  → publishes @leadbay/leadclaw to npm, then ClawHub
  - v*.*.*           → legacy alias for mcp-v* (kept for back-compat)

New preflight-npm job calls `npm whoami` + `npm access list packages @leadbay`
so auth issues fail fast with a clear error, before either publish job starts.

leadclaw release chains npm → ClawHub. npm must go first because
`openclaw.plugin.json#install.npmSpec` resolves installs via npm — ClawHub
pointing at a missing npm version would break installs. ClawHub CLI
(clawhub@^0.9) is pinned and auth'd via `clawhub login --token` (no
CLAWHUB_TOKEN env-var shortcut exists).

Repo hygiene:
  - packages/mcp/src/bin.ts: VERSION now injected at build time by tsup
    `define` from package.json, so `--version` output and the tarball
    version can't drift. vitest.config.ts mirrors the define for tests.
  - Pre-existing typecheck error on bin.ts:170 (stdin data handler typed
    as string | Buffer) fixed so `prepublishOnly` can gate on typecheck.
  - packages/mcp/package.json: `prepublishOnly` now gates build +
    typecheck + test; adds repository/bugs/homepage/author + CHANGELOG
    to files.
  - packages/leadclaw/package.json: adds publishConfig.access=public,
    prepublishOnly with full gate, metadata + keywords, CHANGELOG in files.
  - packages/leadclaw/README.md: created (was missing; listed in files
    array would have broken npm pack).
  - CHANGELOGs seeded for both packages at 0.2.0.
  - RELEASE.md at repo root: tag-driven release runbook + failure-mode
    debugging.
  - ci.yml: now runs typecheck and packs both tarballs on every PR.

Workflow requires NPM_TOKEN and CLAWHUB_TOKEN repo secrets.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@milstan milstan merged commit 876e8f7 into main Apr 21, 2026
1 check passed
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.

1 participant