Skip to content

Commit 94f3ebf

Browse files
committed
feat(napi): add arm64-linux build targets (gnu + musl)
The napi package ships binaries for darwin-arm64/x64, win-x64 and linux-x64-gnu, but not Linux ARM64, so aarch64 Linux hosts have no native binary to load. Add aarch64-unknown-linux-gnu and aarch64-unknown-linux-musl: - declare both triples and add their per-platform npm packages (binding.js already had the arm64 loader branches; they were just never produced) - build matrix: gnu builds natively on the ubuntu-24.04-arm runner; musl builds inside a native arm64 Alpine container (no QEMU). The musl build intentionally omits --target so cargo uses Alpine's native musl toolchain instead of treating it as a cross-compile - wire the two new .node artifacts into the release and publish workflows
1 parent 2f2c866 commit 94f3ebf

8 files changed

Lines changed: 94 additions & 1 deletion

File tree

.github/workflows/build-napi.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ jobs:
5252
set -e &&
5353
npm run build &&
5454
strip *.node
55+
56+
- os: ubuntu-24.04-arm
57+
target: aarch64-unknown-linux-gnu
58+
build: |
59+
set -e &&
60+
npm run build &&
61+
strip *.node
62+
63+
- os: ubuntu-24.04-arm
64+
target: aarch64-unknown-linux-musl
65+
build: |
66+
set -e &&
67+
docker run --rm --platform linux/arm64 \
68+
-v "$GITHUB_WORKSPACE":/src -w /src/crates/bitwarden-napi \
69+
-e CARGO_TARGET_DIR=/tmp/ctarget \
70+
node:lts-alpine sh -c '
71+
apk add --no-cache build-base openssl-dev openssl-libs-static pkgconfig perl rust cargo git &&
72+
npm ci --no-audit --no-fund &&
73+
npx napi build --platform --release --js binding.js --dts binding.d.ts
74+
' &&
75+
strip sdk-napi.linux-arm64-musl.node || true
5576
steps:
5677
- name: Checkout repo
5778
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1

.github/workflows/publish-napi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ jobs:
105105
wget "https://github.com/bitwarden/sdk-sm/releases/download/napi-v${_PKG_VERSION}/sdk-napi.darwin-x64.node"
106106
wget "https://github.com/bitwarden/sdk-sm/releases/download/napi-v${_PKG_VERSION}/sdk-napi.win32-x64-msvc.node"
107107
wget "https://github.com/bitwarden/sdk-sm/releases/download/napi-v${_PKG_VERSION}/sdk-napi.linux-x64-gnu.node"
108+
wget "https://github.com/bitwarden/sdk-sm/releases/download/napi-v${_PKG_VERSION}/sdk-napi.linux-arm64-gnu.node"
109+
wget "https://github.com/bitwarden/sdk-sm/releases/download/napi-v${_PKG_VERSION}/sdk-napi.linux-arm64-musl.node"
108110
mv sdk-napi.*.node ${{ github.workspace }}/crates/bitwarden-napi/artifacts
109111
110112
- name: Set up Node

.github/workflows/release-napi.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,6 @@ jobs:
103103
dist/sdk-napi.darwin-x64.node
104104
dist/sdk-napi.win32-x64-msvc.node
105105
dist/sdk-napi.linux-x64-gnu.node
106+
dist/sdk-napi.linux-arm64-gnu.node
107+
dist/sdk-napi.linux-arm64-musl.node
106108
dist/schemas.ts
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@bitwarden/sdk-napi-linux-arm64-gnu`
2+
3+
This is the **aarch64-unknown-linux-gnu** binary for `@bitwarden/sdk-napi`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@bitwarden/sdk-napi-linux-arm64-gnu",
3+
"version": "1.0.0",
4+
"homepage": "https://github.com/bitwarden/sdk-sm#readme",
5+
"bugs": {
6+
"url": "https://github.com/bitwarden/sdk-sm/issues"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/bitwarden/sdk-sm.git"
11+
},
12+
"license": "SEE LICENSE IN LICENSE",
13+
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
14+
"main": "sdk-napi.linux-arm64-gnu.node",
15+
"files": [
16+
"sdk-napi.linux-arm64-gnu.node"
17+
],
18+
"engines": {
19+
"node": ">= 10"
20+
},
21+
"os": [
22+
"linux"
23+
],
24+
"cpu": [
25+
"arm64"
26+
],
27+
"libc": [
28+
"glibc"
29+
]
30+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `@bitwarden/sdk-napi-linux-arm64-musl`
2+
3+
This is the **aarch64-unknown-linux-musl** binary for `@bitwarden/sdk-napi`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@bitwarden/sdk-napi-linux-arm64-musl",
3+
"version": "1.0.0",
4+
"homepage": "https://github.com/bitwarden/sdk-sm#readme",
5+
"bugs": {
6+
"url": "https://github.com/bitwarden/sdk-sm/issues"
7+
},
8+
"repository": {
9+
"type": "git",
10+
"url": "git+https://github.com/bitwarden/sdk-sm.git"
11+
},
12+
"license": "SEE LICENSE IN LICENSE",
13+
"author": "Bitwarden Inc. <hello@bitwarden.com> (https://bitwarden.com)",
14+
"main": "sdk-napi.linux-arm64-musl.node",
15+
"files": [
16+
"sdk-napi.linux-arm64-musl.node"
17+
],
18+
"engines": {
19+
"node": ">= 10"
20+
},
21+
"os": [
22+
"linux"
23+
],
24+
"cpu": [
25+
"arm64"
26+
],
27+
"libc": [
28+
"musl"
29+
]
30+
}

crates/bitwarden-napi/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
"name": "sdk-napi",
4444
"triples": {
4545
"additional": [
46-
"aarch64-apple-darwin"
46+
"aarch64-apple-darwin",
47+
"aarch64-unknown-linux-gnu",
48+
"aarch64-unknown-linux-musl"
4749
]
4850
}
4951
}

0 commit comments

Comments
 (0)