Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ jobs:
ALGOLIA_API_URL: ${{ secrets.ALGOLIA_API_URL }}
ALGOLIA_OAUTH_CLIENT_ID: ${{ secrets.ALGOLIA_OAUTH_CLIENT_ID }}
ALGOLIA_OAUTH_SCOPE: ${{ secrets.ALGOLIA_OAUTH_SCOPE }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"
- name: Publish npm packages
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ github.ref_name }}
run: ./scripts/npm-publish.sh
- name: Docs checkout
uses: actions/checkout@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
vendor/

# local build
algolia
/algolia

.gocache/

Expand Down
3 changes: 3 additions & 0 deletions npm/algolia-darwin-arm64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const path = require('path');
module.exports = { binPath: path.join(__dirname, 'bin', 'algolia') };
24 changes: 24 additions & 0 deletions npm/algolia-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/cli-darwin-arm64",
"version": "5.8.2",
"description": "darwin arm64 binary for @algolia/cli",
"os": [
"darwin"
],
"cpu": [
"arm64"
],
"files": [
"bin/algolia",
"index.js"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
3 changes: 3 additions & 0 deletions npm/algolia-darwin-x64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const path = require('path');
module.exports = { binPath: path.join(__dirname, 'bin', 'algolia') };
24 changes: 24 additions & 0 deletions npm/algolia-darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/cli-darwin-x64",
"version": "5.8.2",
"description": "darwin x64 binary for @algolia/cli",
"os": [
"darwin"
],
"cpu": [
"x64"
],
"files": [
"bin/algolia",
"index.js"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
3 changes: 3 additions & 0 deletions npm/algolia-linux-arm64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const path = require('path');
module.exports = { binPath: path.join(__dirname, 'bin', 'algolia') };
24 changes: 24 additions & 0 deletions npm/algolia-linux-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/cli-linux-arm64",
"version": "5.8.2",
"description": "linux arm64 binary for @algolia/cli",
"os": [
"linux"
],
"cpu": [
"arm64"
],
"files": [
"bin/algolia",
"index.js"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
3 changes: 3 additions & 0 deletions npm/algolia-linux-x64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const path = require('path');
module.exports = { binPath: path.join(__dirname, 'bin', 'algolia') };
24 changes: 24 additions & 0 deletions npm/algolia-linux-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/cli-linux-x64",
"version": "5.8.2",
"description": "linux x64 binary for @algolia/cli",
"os": [
"linux"
],
"cpu": [
"x64"
],
"files": [
"bin/algolia",
"index.js"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
3 changes: 3 additions & 0 deletions npm/algolia-win32-arm64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const path = require('path');
module.exports = { binPath: path.join(__dirname, 'bin', 'algolia.exe') };
24 changes: 24 additions & 0 deletions npm/algolia-win32-arm64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/cli-win32-arm64",
"version": "5.8.2",
"description": "win32 arm64 binary for @algolia/cli",
"os": [
"win32"
],
"cpu": [
"arm64"
],
"files": [
"bin/algolia.exe",
"index.js"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
3 changes: 3 additions & 0 deletions npm/algolia-win32-x64/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';
const path = require('path');
module.exports = { binPath: path.join(__dirname, 'bin', 'algolia.exe') };
24 changes: 24 additions & 0 deletions npm/algolia-win32-x64/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@algolia/cli-win32-x64",
"version": "5.8.2",
"description": "win32 x64 binary for @algolia/cli",
"os": [
"win32"
],
"cpu": [
"x64"
],
"files": [
"bin/algolia.exe",
"index.js"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
42 changes: 42 additions & 0 deletions npm/algolia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Algolia CLI

The official Algolia CLI lets you manage your Algolia resources — indices, records, API keys, and synonyms — directly from the command line.

> This package installs a prebuilt Go binary. No Node.js runtime dependency is required after install.

## Installation

```sh
npm install -g @algolia/cli
```

Or run without installing:

```sh
npx @algolia/cli --help
```

## Usage

```sh
algolia --help
algolia search --index my-index --query "foo"
algolia indices list
algolia apikeys list
```

## Documentation

Full documentation: [algolia.com/doc/tools/cli](https://algolia.com/doc/tools/cli/)

## Supported platforms

| OS | x64 | arm64 |
|---------|-----|-------|
| macOS | ✓ | ✓ |
| Linux | ✓ | ✓ |
| Windows | ✓ | ✓ |

## Issues

[github.com/algolia/cli/issues](https://github.com/algolia/cli/issues)
26 changes: 26 additions & 0 deletions npm/algolia/bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node
'use strict';

const { execFileSync } = require('child_process');

let binPath;
switch (`${process.platform}-${process.arch}`) {
case 'darwin-x64': ({ binPath } = require('@algolia/cli-darwin-x64')); break;
case 'darwin-arm64': ({ binPath } = require('@algolia/cli-darwin-arm64')); break;
case 'linux-x64': ({ binPath } = require('@algolia/cli-linux-x64')); break;
case 'linux-arm64': ({ binPath } = require('@algolia/cli-linux-arm64')); break;
case 'win32-x64': ({ binPath } = require('@algolia/cli-win32-x64')); break;
case 'win32-arm64': ({ binPath } = require('@algolia/cli-win32-arm64')); break;
default:
console.error(
`algolia: unsupported platform ${process.platform}/${process.arch}\n` +
`Install the appropriate platform package manually: npm install @algolia/cli-${process.platform}-${process.arch}`
);
process.exit(1);
}

try {
execFileSync(binPath, process.argv.slice(2), { stdio: 'inherit' });
} catch (e) {
process.exit(e.status ?? 1);
}
38 changes: 38 additions & 0 deletions npm/algolia/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@algolia/cli",
"version": "0.0.0",
"description": "The official Algolia CLI — manage indices, records, API keys, and synonyms from the command line",
"bin": {
"algolia": "bin/run.js"
},
"files": [
"bin/run.js",
"README.md"
],
"optionalDependencies": {
"@algolia/cli-darwin-x64": "0.0.0",
"@algolia/cli-darwin-arm64": "0.0.0",
"@algolia/cli-linux-x64": "0.0.0",
"@algolia/cli-linux-arm64": "0.0.0",
"@algolia/cli-win32-x64": "0.0.0",
"@algolia/cli-win32-arm64": "0.0.0"
},
"keywords": [
"algolia",
"cli",
"search",
"indices",
"records",
"api-keys",
"synonyms"
],
"license": "MIT",
"homepage": "https://algolia.com/doc/tools/cli/",
"bugs": {
"url": "https://github.com/algolia/cli/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/algolia/cli.git"
}
}
63 changes: 63 additions & 0 deletions scripts/npm-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
set -euo pipefail

# Strip leading 'v' from the tag (e.g. v1.8.2 -> 1.8.2)
VERSION="${VERSION#v}"

# Offset the major version by +4 so the npm package starts at 5.x
# (the old @algolia/cli package was at 4.x — a completely different tool)
IFS='.' read -r major minor patch <<< "$VERSION"
VERSION="$((major + 4)).$minor.$patch"

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
NPM_DIR="$REPO_ROOT/npm"
DIST_DIR="$REPO_ROOT/dist"

DRY_RUN=""
if [[ "${1:-}" == "--dry-run" ]]; then
DRY_RUN="--dry-run"
fi

# Format: "npm-package-name:dist-relative-path"
PLATFORMS=(
"algolia-darwin-x64:algolia_darwin_amd64_v1/algolia"
"algolia-darwin-arm64:algolia_darwin_arm64/algolia"
"algolia-linux-x64:algolia_linux_amd64_v1/algolia"
"algolia-linux-arm64:algolia_linux_arm64/algolia"
"algolia-win32-x64:algolia_windows_amd64_v1/algolia.exe"
"algolia-win32-arm64:algolia_windows_arm64/algolia.exe"
)

# Publish platform packages
for entry in "${PLATFORMS[@]}"; do
pkg="${entry%%:*}"
dist_path="${entry#*:}"
src="$DIST_DIR/$dist_path"
dest_dir="$NPM_DIR/$pkg/bin"
binary_name="$(basename "$dist_path")"

echo "Publishing @algolia/$pkg@$VERSION"

if [[ -z "$DRY_RUN" ]]; then
cp "$src" "$dest_dir/$binary_name"
if [[ "$binary_name" != *.exe ]]; then
chmod +x "$dest_dir/$binary_name"
fi
fi

npm --prefix "$NPM_DIR/$pkg" version --no-git-tag-version "$VERSION"
npm publish "$NPM_DIR/$pkg" --access public $DRY_RUN
done

# Update coordinator package versions to match and publish
for entry in "${PLATFORMS[@]}"; do
pkg="${entry%%:*}"
# Pin the optionalDependency version in the coordinator package.json to match the published platform packages
sed -i.bak "s|\"@algolia/$pkg\": \"[^\"]*\"|\"@algolia/$pkg\": \"$VERSION\"|g" "$NPM_DIR/algolia/package.json"
rm -f "$NPM_DIR/algolia/package.json.bak"
done

npm --prefix "$NPM_DIR/algolia" version --no-git-tag-version "$VERSION"

echo "Publishing @algolia/cli@$VERSION"
npm publish "$NPM_DIR/algolia" --access public $DRY_RUN
Loading