Skip to content

Phase 1 + Phase 2 (npm scope) for issue #188: cargo-binstall + npm distribution#189

Merged
sdairs merged 5 commits into
mainfrom
issue-188-binstall-dist-pypi
May 18, 2026
Merged

Phase 1 + Phase 2 (npm scope) for issue #188: cargo-binstall + npm distribution#189
sdairs merged 5 commits into
mainfrom
issue-188-binstall-dist-pypi

Conversation

@sdairs
Copy link
Copy Markdown
Collaborator

@sdairs sdairs commented May 18, 2026

Closes part of #188.

Adds two installation paths for clickhousectl so the obvious cargo binstall and npm install -g incantations work after the next tag. Brew, the shell installer, full cargo-dist migration, and PyPI (Phase 3) are intentionally not in this PR — they will follow.

Summary

Phase 1 — cargo-binstall + crates.io readiness

  • release.yml builds now produce clickhousectl-{target}-v{version}.tar.gz archives, each containing a single directory of the same name with the clickhousectl binary inside (the cargo-binstall naming convention). Smoke-test job and install.sh updated to consume the new layout.
  • New publish-crates job tags-trigger publishes both crates to crates.io. It is idempotent for clickhouse-cloud-api (skips when the version is already on crates.io) so the API client can lag behind clickhousectl version bumps.
  • crates/clickhousectl/Cargo.toml gains description, license = "Apache-2.0", repository, homepage, keywords, categories, and an explicit [package.metadata.binstall] block.
  • crates/clickhouse-cloud-api/Cargo.toml license corrected MITApache-2.0 to match the repo LICENSE; same metadata fields added.
  • README gets cargo binstall, cargo install clickhousectl, and direct-download sections.

Phase 2 (npm scope only)

  • New npm/ wrapper package: bin/cli.js shim execs the binary that install.js downloads from the matching GitHub release at install time (single-package postinstall layout — simpler than dist's subpackage approach and decoupled from any future cargo-dist migration). Exposes both clickhousectl and chctl bin commands.
  • New publish-npm job in release.yml: uses id-token: write for npm OIDC trusted publishing, runs npm publish --provenance --access public, and deliberately does not set NODE_AUTH_TOKEN (per npm docs, even an empty value short-circuits the OIDC flow).
  • Pinned actions/setup-node@v6.4.0 by SHA to match the zizmor hardening style.

One-time manual setup before the next tag

  • Add CARGO_REGISTRY_TOKEN repo secret for crates.io publishes.
  • Squat clickhousectl on crates.io (first publish via cargo publish locally) and on npm (seed publish with a granular token).
  • Configure the npm trusted publisher on npmjs.com pointing at ClickHouse/clickhousectl + release.yml + the publish-npm job; revoke the granular npm token once OIDC is wired.

Test plan

Most of this is workflow / packaging plumbing that only runs on a tag push, so the meaningful tests are:

  • cargo metadata and cargo build --workspace succeed with the new manifests.
  • cargo publish --dry-run -p clickhouse-cloud-api packages cleanly.
  • npm pack --dry-run in npm/ produces a tarball with the expected 4 files.
  • node --check passes for install.js and bin/cli.js.
  • release.yml YAML parses; job graph is build → smoke-test → release → {publish-crates, publish-npm}.
  • Verify on first tag push: archives match clickhousectl-{target}-v{version}.tar.gz, cargo binstall clickhousectl resolves from crates.io, npm install -g clickhousectl installs the binary on macOS + Linux.

🤖 Generated with Claude Code

sdairs added 2 commits May 18, 2026 18:43
- Release workflow now produces clickhousectl-{target}-v{version}.tar.gz
  archives containing a directory of the same name with the binary
  inside, matching the cargo-binstall naming convention. Smoke test and
  install.sh updated to consume the new archive layout.
- Add publish-crates job to release.yml that publishes both crates on
  tag (requires CARGO_REGISTRY_TOKEN secret).
- Add description / license / repository / keywords / categories /
  [package.metadata.binstall] to clickhousectl. Correct cloud-api
  license MIT -> Apache-2.0 to match the repo LICENSE.
- README: document cargo binstall, cargo install, and the new archive
  naming for direct downloads.

Issue: #188
Adds an npm/ wrapper package that downloads the matching prebuilt
clickhousectl binary from the GitHub release at install time, and a
publish-npm job in release.yml that publishes it to npm using OIDC
trusted publishing (no long-lived NPM_TOKEN).

Single-package postinstall layout (vs. dist's subpackage approach) —
simpler to reason about and decoupled from any future cargo-dist
migration. Exposes both `clickhousectl` and `chctl` bin commands.

publish-crates is now idempotent for clickhouse-cloud-api: it skips the
publish step when the version is already on crates.io, so the API
client can lag behind clickhousectl version bumps.

Phase 2 brew / shell / PS installers and the full cargo-dist migration
are intentionally deferred — npm-only is the scope of this commit.

One-time setup the maintainer still needs to do for the next tag:
- Squat the `clickhousectl` name on crates.io (cargo publish) and npm
  (manual seed publish with a granular token).
- Configure the npm trusted publisher on npmjs.com pointing at
  ClickHouse/clickhousectl + release.yml + publish-npm.
- Add CARGO_REGISTRY_TOKEN repo secret.

Issue: #188
@sdairs sdairs requested a review from iskakaushik as a code owner May 18, 2026 17:51
@sdairs sdairs temporarily deployed to cloud-integration May 18, 2026 17:51 — with GitHub Actions Inactive
@sdairs sdairs marked this pull request as draft May 18, 2026 18:04
@sdairs sdairs temporarily deployed to cloud-integration May 18, 2026 18:19 — with GitHub Actions Inactive
sdairs added 2 commits May 18, 2026 19:30
chmod +x on the shim file matches how npm will land it on install, and
makes `./bin/cli.js` directly invokable when developing locally. Plus
ignore the npm/vendor, package-lock, *.tgz, and node_modules paths
produced when packing or running install.js by hand.
Lets us trigger workflow_dispatch on a branch to validate the build
matrix, static-linking check, smoke tests, and archive format without
risking a junk GitHub Release named after the branch. publish-crates
and publish-npm already had this guard; release didn't.
@sdairs sdairs temporarily deployed to cloud-integration May 18, 2026 18:46 — with GitHub Actions Inactive
@sdairs sdairs linked an issue May 18, 2026 that may be closed by this pull request
@sdairs sdairs marked this pull request as ready for review May 18, 2026 20:52
@sdairs sdairs merged commit 2e04ce2 into main May 18, 2026
28 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.

Distribute clickhousectl via cargo-binstall, dist (brew/npm), and PyPI

2 participants