Skip to content

feat: distribute CLI via npm#213

Merged
dylantientcheu merged 18 commits into
mainfrom
feat/npm-package
May 19, 2026
Merged

feat: distribute CLI via npm#213
dylantientcheu merged 18 commits into
mainfrom
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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an npm distribution channel for the Algolia CLI using a coordinator package (@algolia/cli) plus platform-specific optional dependency packages, and wires publishing into the tag-based release workflow.

Changes:

  • Introduces npm packages under npm/ (coordinator + 6 platform packages) and a Node.js shim to execute the packaged Go binary.
  • Adds scripts/npm-publish.sh to version/copy binaries from GoReleaser dist/ and publish all npm packages.
  • Updates the release GitHub Actions workflow to set up Node.js and publish to npm after GoReleaser; adjusts .gitignore to allow tracking npm/algolia/.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
scripts/npm-publish.sh New publish script to version/copy GoReleaser artifacts into npm packages and publish them
npm/algolia/README.md Coordinator package README and usage/docs
npm/algolia/package.json Defines @algolia/cli coordinator with optionalDependencies and algolia bin shim
npm/algolia/bin/run.js Node shim that selects and executes the correct platform binary
npm/algolia-darwin-x64/package.json macOS x64 binary package metadata
npm/algolia-darwin-x64/index.js Exports bin path for macOS x64 package
npm/algolia-darwin-arm64/package.json macOS arm64 binary package metadata
npm/algolia-darwin-arm64/index.js Exports bin path for macOS arm64 package
npm/algolia-linux-x64/package.json Linux x64 binary package metadata
npm/algolia-linux-x64/index.js Exports bin path for Linux x64 package
npm/algolia-linux-arm64/package.json Linux arm64 binary package metadata
npm/algolia-linux-arm64/index.js Exports bin path for Linux arm64 package
npm/algolia-win32-x64/package.json Windows x64 binary package metadata
npm/algolia-win32-x64/index.js Exports bin path for Windows x64 package
npm/algolia-win32-arm64/package.json Windows arm64 binary package metadata
npm/algolia-win32-arm64/index.js Exports bin path for Windows arm64 package
.gitignore Scopes /algolia ignore rule so npm/algolia/ is not ignored
.github/workflows/releases.yml Adds Node setup + npm publish step after GoReleaser

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/npm-publish.sh Outdated
Comment thread scripts/npm-publish.sh Outdated
Comment thread scripts/npm-publish.sh Outdated
Comment thread npm/algolia/README.md Outdated
tkrugg and others added 2 commits May 11, 2026 15:14
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sarahdayan
Copy link
Copy Markdown
Member

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

Indeed! I never used OIDC directly for first-time publish, I only migrated existing ones from token to OIDC.

So I think this is fine now and you can set up OIDC in a followup PR.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated 2 comments.

Comment thread scripts/npm-publish.sh Outdated
Comment thread scripts/npm-test-local.sh Outdated
tkrugg and others added 2 commits May 19, 2026 12:39
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dylantientcheu dylantientcheu merged commit 2aeac21 into main May 19, 2026
3 checks passed
@dylantientcheu dylantientcheu deleted the feat/npm-package branch May 19, 2026 16:19
@tkrugg tkrugg restored the feat/npm-package branch May 19, 2026 18:56
@tkrugg tkrugg deleted the feat/npm-package branch May 19, 2026 19:00
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.

4 participants