ci(release): publish binaries to the GitHub Packages npm registry - #19
Merged
Conversation
Add a second distribution channel alongside the release assets: one wrapper package (`@jdh313/agentforge`) plus one package per platform, each guarded by `os`/`cpu` so a package manager installs only the matching binary. This is the @biomejs/biome shape — no postinstall script, which install-script-disabled CI and offline installs both break on. The assets stay the anonymous path. GitHub Packages' npm registry requires a token even for a public package, so npm serves the repos that already have one and the release binaries serve everyone else. Ordering is load-bearing in two places. Platform packages publish before the wrapper, whose optionalDependencies pin them exactly, so a mid-run failure leaves inert orphans rather than an entry point that resolves to nothing. And `publish-npm` runs after `publish`, so a tagged release never exists without a downloadable binary. Auth is the run's own GITHUB_TOKEN under `packages: write` — no long-lived npm credential to store or rotate. Verified locally: `--dry-run` publishes all three packages in order; a hand-assembled node_modules resolves the shim and runs `--version` and `list-targets`; removing the platform package exits 1 with the release-page fallback. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LxNdWk6ZUzq6uWFtd94yWD
|
🎉 This PR is included in version 0.4.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a second distribution channel alongside the release assets, so
jdh-agentsandndrcan consume agentforge as a dependency instead of hand-rolling fetch-and-verify code.Shape
One wrapper package (
@jdh313/agentforge) declaring threeoptionalDependencies—@jdh313/agentforge-{darwin-arm64,linux-arm64,linux-x64}— each guarded byos/cpuso only the matching binary installs. This is the@biomejs/biomeshape rather than esbuild's: no postinstall script, which hardened CI (install scripts disabled) and offline installs both break on.The wrapper's
binis a small shim that computes@jdh313/agentforge-${process.platform}-${process.arch}andrequire.resolves it. No platform table — the release matrix already names every asset with Node's own spellings, so a table would be a second copy that can drift.Why GitHub Packages and not npmjs
The release assets stay and remain the anonymous path. GitHub Packages' npm registry requires a token even for a public package, so this channel serves repos that already have one; anyone else still gets
curl+SHA256SUMS.Chosen over npmjs.org for reversibility. An npm publish is close to permanent —
package@versioncan never be reused, and after 72 hours unpublishing requires no dependents, <300 weekly downloads, and a single maintainer. A GitHub package can be deleted outright. Given the only current consumers are two of my own repos, buying reversibility is the better trade. npmjs stays available as a later move, and the unscoped nameagentforgeis currently free there.Ordering (load-bearing in two places)
publish-npmruns afterpublish. A tagged release must never exist without a downloadable binary; npm is the part allowed to fail late.Auth
NODE_AUTH_TOKENis the run's ownGITHUB_TOKENunder a newpackages: writepermission. No long-lived npm credential to store or rotate.Requires one manual step after merge: each consuming repo (
jdh-agents,ndr) needs a one-time grant under the package's Manage Actions access → Add Repository. Automatic access covers only the linked repo; that grant is what lets theirGITHUB_TOKENinstall.Testing
Verified locally, not just dry-run:
DRY_RUN=1 AGENTFORGE_VERSION=v0.3.0 node scripts/publish-npm.mjs— all three packages, correct order, correct registry. Tarball 24.1 MB / 64.6 MB unpacked, in line with@biomejs/cli-darwin-arm64at 57.6 MB.node_modules/@jdh313/layout: shim resolves and executes,--version→0.3.0,list-targetscorrect.setup-nodepinned to the realv7.0.0SHA, matching the workflow's other v7/v8 pins;registry-urlandscopeconfirmed present in that version'saction.yml.Risk surface
Additive. Touches no build, compile, or existing publish step — the release assets are produced and attached exactly as before.
ci:type, so merging cuts no release; the first real publish happens on the nextfeat:/fix:.Untested until then: the actual authenticated publish. A dry-run on a branch is not possible, since
.releaserc.jsonpinsbranches: ["main"]and every downstream job gates onreleased == 'true'.Rollback
Revert the commit. The
publish-npmjob disappears; assets are unaffected. Any already-published packages can be deleted from the repo's Packages tab.🤖 Generated with Claude Code
https://claude.ai/code/session_01LxNdWk6ZUzq6uWFtd94yWD