Skip to content

feat: distribute CLI via npm#213

Open
tkrugg wants to merge 6 commits intomainfrom
feat/npm-package
Open

feat: distribute CLI via npm#213
tkrugg wants to merge 6 commits intomainfrom
feat/npm-package

Conversation

@tkrugg
Copy link
Copy Markdown
Collaborator

@tkrugg tkrugg commented May 7, 2026

Summary

  • Adds @algolia/cli to npm so users can install/run the CLI without Homebrew or a direct binary download
  • Uses the platform-specific optional packages pattern (same as esbuild, bun, turbo): one coordinator package with 6 platform packages as optionalDependencies
  • Publish runs automatically after GoReleaser on every v* tag; npm version is offset by +4 (Go v1.x → npm 5.x) to supersede the old abandoned @algolia/cli v4 package

Usage after release

# global install
npm install -g @algolia/cli
algolia --version

# one-off
npx @algolia/cli --help

What's included

File Purpose
npm/algolia/ Coordinator package (@algolia/cli) with Node.js shim
npm/algolia-{darwin,linux,win32}-{x64,arm64}/ Per-platform binary packages
scripts/npm-publish.sh Copies GoReleaser dist binaries and publishes all 7 packages
.github/workflows/releases.yml Adds Node.js setup + publish step after GoReleaser
.gitignore Scopes the algolia ignore rule to repo root so npm/algolia/ is tracked

Pre-requisites (already done)

  • NPM_TOKEN secret added to repo GitHub Actions secrets

Adds @algolia/cli to npm so users can install with `npm install -g @algolia/cli`
or run with `npx @algolia/cli`. Uses the esbuild/bun pattern: one coordinator
package with six platform-specific optional dependencies that each ship the
native Go binary. The publish step runs automatically after GoReleaser on
every v* tag push.

- npm/algolia/ — coordinator package (@algolia/cli) with Node.js shim
- npm/algolia-{darwin,linux,win32}-{x64,arm64}/ — per-platform binary packages
- scripts/npm-publish.sh — copies dist binaries and publishes all 7 packages
- .github/workflows/releases.yml — adds Node.js setup + publish step after GoReleaser
- .gitignore — scope the `algolia` ignore rule to the repo root to allow npm/algolia/
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 7, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes.

@sarahdayan
Copy link
Copy Markdown
Member

You can do without NPM_TOKEN and instead use OIDC, which is the recommended way of publishing to npm since they sunsetted classic tokens.

This way, we will never need to rotate tokens.

@tkrugg
Copy link
Copy Markdown
Collaborator Author

tkrugg commented May 7, 2026

You can do without NPM_TOKEN and instead use OIDC, which is the recommended way of publishing to npm since they sunsetted classic tokens.

This way, we will never need to rotate tokens.

Thanks! I didn't know about OIDC ☺️
reading the docs it looks like I need to publish the 6 packages manually first before I can claim them on NPM (currently packages don't exist, I wanted this PR to create them)
is that correct?

I see an issue confirming this it seems: npm/cli#8544

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