Skip to content

Commit 00a4c1d

Browse files
committed
ci: unified npm package with native binding + CLI binary
The `authy-cli` npm package now ships both: - napi-rs native .node files (import { Authy } from "authy-cli") - prebuilt CLI binaries (authy command on PATH) One `npm install authy-cli` gives users the Node.js binding AND the CLI. Release workflow builds napi-rs cdylib for 5 platforms in parallel, then collects all .node files and CLI binaries into a single npm publish.
1 parent 3aee370 commit 00a4c1d

File tree

4 files changed

+84
-6
lines changed

4 files changed

+84
-6
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ jobs:
162162
path: bindings/node/*.node
163163
if-no-files-found: error
164164

165+
# ── Publish unified npm package (native binding + CLI binary) ───
166+
165167
npm-publish:
166168
name: Publish npm package
167-
needs: [node-build, release]
169+
needs: [build, node-build, release]
168170
runs-on: ubuntu-latest
169171
steps:
170172
- uses: actions/checkout@v4
@@ -174,15 +176,53 @@ jobs:
174176
node-version: 20
175177
registry-url: https://registry.npmjs.org
176178

177-
- name: Download all native artifacts
179+
# Collect napi-rs .node files
180+
- name: Download native binding artifacts
178181
uses: actions/download-artifact@v4
179182
with:
180183
pattern: node-*
181184
path: bindings/node
182185
merge-multiple: true
183186

184-
- name: List native modules
185-
run: ls -la bindings/node/*.node
187+
# Collect prebuilt CLI binaries
188+
- name: Download CLI binary artifacts
189+
uses: actions/download-artifact@v4
190+
with:
191+
path: artifacts
192+
193+
- name: Place CLI binaries into package
194+
run: |
195+
# Linux x64
196+
tar xzf artifacts/authy-x86_64-unknown-linux-gnu/authy-x86_64-unknown-linux-gnu.tar.gz -C /tmp
197+
mv /tmp/authy bindings/node/bin/authy-linux-x64
198+
199+
# Linux arm64
200+
tar xzf artifacts/authy-aarch64-unknown-linux-gnu/authy-aarch64-unknown-linux-gnu.tar.gz -C /tmp
201+
mv /tmp/authy bindings/node/bin/authy-linux-arm64
202+
203+
# macOS x64
204+
tar xzf artifacts/authy-x86_64-apple-darwin/authy-x86_64-apple-darwin.tar.gz -C /tmp
205+
mv /tmp/authy bindings/node/bin/authy-darwin-x64
206+
207+
# macOS arm64
208+
tar xzf artifacts/authy-aarch64-apple-darwin/authy-aarch64-apple-darwin.tar.gz -C /tmp
209+
mv /tmp/authy bindings/node/bin/authy-darwin-arm64
210+
211+
# Windows x64
212+
cd artifacts/authy-x86_64-pc-windows-msvc
213+
7z x authy-x86_64-pc-windows-msvc.zip -o/tmp/win
214+
cd ../..
215+
mv /tmp/win/authy.exe bindings/node/bin/authy-win32-x64.exe
216+
217+
# Make all binaries executable
218+
chmod +x bindings/node/bin/authy-*
219+
220+
- name: List package contents
221+
run: |
222+
echo "=== Native modules ==="
223+
ls -la bindings/node/*.node
224+
echo "=== CLI binaries ==="
225+
ls -la bindings/node/bin/
186226
187227
- name: Extract version from tag
188228
id: version

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ bindings/*/target/
4040
bindings/*/Cargo.lock
4141
bindings/node/node_modules/
4242
bindings/node/*.node
43+
bindings/node/bin/authy-*

bindings/node/bin/authy

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env node
2+
"use strict";
3+
4+
const { execFileSync } = require("child_process");
5+
const path = require("path");
6+
7+
const PLATFORMS = {
8+
"linux-x64": "authy-linux-x64",
9+
"linux-arm64": "authy-linux-arm64",
10+
"darwin-x64": "authy-darwin-x64",
11+
"darwin-arm64": "authy-darwin-arm64",
12+
"win32-x64": "authy-win32-x64.exe",
13+
};
14+
15+
const key = `${process.platform}-${process.arch}`;
16+
const binary = PLATFORMS[key];
17+
18+
if (!binary) {
19+
console.error(`Unsupported platform: ${key}`);
20+
console.error(`Supported: ${Object.keys(PLATFORMS).join(", ")}`);
21+
process.exit(1);
22+
}
23+
24+
const binPath = path.join(__dirname, binary);
25+
26+
try {
27+
execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
28+
} catch (err) {
29+
if (err.status !== null) {
30+
process.exit(err.status);
31+
}
32+
throw err;
33+
}

bindings/node/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
{
22
"name": "authy-cli",
33
"version": "0.7.1",
4-
"description": "Native Node.js binding for the authy secrets manager (Rust-powered)",
4+
"description": "Secrets store & dispatch for AI agents — native Node.js binding + CLI binary (Rust-powered)",
55
"main": "index.js",
66
"types": "index.d.ts",
7+
"bin": {
8+
"authy": "bin/authy"
9+
},
710
"license": "MIT",
811
"repository": {
912
"type": "git",
1013
"url": "git+https://github.com/eric8810/authy.git",
1114
"directory": "bindings/node"
1215
},
13-
"keywords": ["secrets", "vault", "agents", "ai", "encryption", "napi-rs"],
16+
"keywords": ["secrets", "vault", "agents", "ai", "encryption", "napi-rs", "cli"],
1417
"files": [
1518
"index.js",
1619
"index.d.ts",
20+
"bin/",
1721
"*.node"
1822
],
1923
"napi": {

0 commit comments

Comments
 (0)