Skip to content

Publish @funky-dev/cli to npm on release - #4

Merged
jinxi97 merged 1 commit into
mainfrom
jinxi97/npm-publish
Oct 29, 2026
Merged

jinxi97 merged 1 commit into
mainfrom
jinxi97/npm-publish

Conversation

@jinxi97

@jinxi97 jinxi97 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

What

npm install -g @funky-dev/cli (or npx @funky-dev/cli login) installs the funky command.

  • npm/publish.mjs turns GoReleaser's dist/ into npm packages: one per platform (@funky-dev/cli-darwin-arm64, -darwin-x64, -linux-arm64, -linux-x64, -win32-arm64, -win32-x64), each holding only its binary and restricted with os/cpu, then @funky-dev/cli. The main package lists them all as optionalDependencies, so npm installs only the matching one, and bin/funky.js runs it, passing through arguments, exit code and signals. Same approach as esbuild and Biome. There is no postinstall download, so it works with --ignore-scripts and behind proxies.
  • Every package gets the tag's version. Pre-release tags (v0.2.0-rc.1) publish under npm's next tag, so they're not what npm i installs.
  • Release workflow: a separate npm job runs after the GitHub release, using the dist/ artifact. It publishes with provenance and skips versions that are already published, so a failed publish can be fixed with "Re-run failed jobs" without touching the GitHub release.
  • CI: packs all the packages from the snapshot build (--dry-run).

Auth

The first publish uses the NPM_TOKEN repo secret (already set; expires Nov 5). npm only allows trusted publishing (OIDC, no token) to be configured once a package exists, so after the first release: add funkyhq/cli / release.yml as a trusted publisher on each of the 7 packages, then delete the secret. The job already has id-token: write for that.

Testing

  • goreleaser release --snapshot --clean and then node npm/publish.mjs --dry-run: 7 tarballs; the binary keeps its executable bit; versions and optionalDependencies are filled in.
  • Installed the packed main and darwin-arm64 tarballs with npm install -g --prefix <tmp>. funky --version, funky whoami (a real production login) and a failing funky apply work through the shim, with exit codes passed through. With the platform package removed, it prints how to fix the install.

🤖 Generated with Claude Code

Each release now also publishes one npm package per platform holding
that platform's binary, and @funky-dev/cli, which lists them as optional
dependencies and runs the matching one from a small Node shim, the way
esbuild and Biome ship. No postinstall download, so it works with
--ignore-scripts.

Publishing runs in its own job after the GitHub release, with
provenance, and skips versions already out so a failed run can be
re-run. CI packs the packages from the snapshot build.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jinxi97
jinxi97 merged commit 6cf6aaf into main Oct 29, 2026
2 checks 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