Skip to content

Commit 98990cc

Browse files
feat(npm): add Linux musl and ARM64 N-API binaries (#233)
Adds x86_64-unknown-linux-musl, aarch64-unknown-linux-gnu, and aarch64-unknown-linux-musl to the napi build targets so @firecrawl/pdf-inspector works on Alpine and ARM64 Linux deployments. - gnu arm64 cross-compiles with --use-napi-cross (old-glibc sysroot), musl targets with -x (zig + cargo-zigbuild), per the napi-rs template - new platform packages carry npm libc metadata (glibc/musl) - smoke-test job runs napi/test.mjs on all six targets before publish (Alpine containers for musl, ubuntu-24.04-arm runners for ARM64) - bump to 1.12.0 to trigger publishing of all platform packages Closes #216
1 parent a15ec2d commit 98990cc

5 files changed

Lines changed: 129 additions & 18 deletions

File tree

.github/workflows/publish.yml

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ jobs:
6161
include:
6262
- os: ubuntu-latest
6363
target: x86_64-unknown-linux-gnu
64+
# napi-cross builds gnu targets against an old glibc sysroot for
65+
# broad distro compatibility; musl targets cross-compile with
66+
# zig via cargo-zigbuild (napi's -x flag).
67+
- os: ubuntu-latest
68+
target: aarch64-unknown-linux-gnu
69+
build-flags: --use-napi-cross
70+
- os: ubuntu-latest
71+
target: x86_64-unknown-linux-musl
72+
build-flags: -x
73+
- os: ubuntu-latest
74+
target: aarch64-unknown-linux-musl
75+
build-flags: -x
6476
- os: macos-14
6577
target: aarch64-apple-darwin
6678
- os: windows-latest
@@ -70,30 +82,47 @@ jobs:
7082

7183
- name: Install Rust
7284
uses: dtolnay/rust-toolchain@stable
85+
with:
86+
targets: ${{ matrix.target }}
7387

7488
- uses: oven-sh/setup-bun@v2
7589
with:
7690
bun-version: latest
7791

92+
- name: Install zig
93+
if: contains(matrix.target, 'musl')
94+
uses: mlugg/setup-zig@v2
95+
with:
96+
version: 0.14.1
97+
98+
- name: Install cargo-zigbuild
99+
if: contains(matrix.target, 'musl')
100+
uses: taiki-e/install-action@v2
101+
env:
102+
GITHUB_TOKEN: ${{ github.token }}
103+
with:
104+
tool: cargo-zigbuild
105+
78106
- name: Cache cargo
79107
uses: actions/cache@v4
80108
with:
81109
path: |
82110
~/.cargo/registry/index/
83111
~/.cargo/registry/cache/
84112
~/.cargo/git/db/
113+
~/.napi-rs
85114
napi/target/
86-
key: ${{ runner.os }}-cargo-napi-${{ hashFiles('**/Cargo.lock') }}
115+
key: ${{ matrix.target }}-cargo-napi-${{ hashFiles('**/Cargo.lock') }}
87116
restore-keys: |
88-
${{ runner.os }}-cargo-napi-
117+
${{ matrix.target }}-cargo-napi-
89118
90119
- name: Install dependencies
91120
working-directory: napi
92121
run: bun install
93122

94123
- name: Build native addon
95124
working-directory: napi
96-
run: bunx napi build --platform --release
125+
run: bunx napi build --platform --release --target ${{ matrix.target }} ${{ matrix.build-flags }}
97126

98127
- name: Upload native binary
99128
uses: actions/upload-artifact@v4
@@ -112,9 +141,54 @@ jobs:
112141
napi/index.d.ts
113142
if-no-files-found: error
114143

144+
smoke-test:
145+
name: Smoke test ${{ matrix.target }}
146+
needs: [check-version, build]
147+
runs-on: ${{ matrix.os }}
148+
strategy:
149+
fail-fast: false
150+
matrix:
151+
include:
152+
- os: ubuntu-latest
153+
target: x86_64-unknown-linux-gnu
154+
- os: ubuntu-latest
155+
target: x86_64-unknown-linux-musl
156+
- os: ubuntu-24.04-arm
157+
target: aarch64-unknown-linux-gnu
158+
- os: ubuntu-24.04-arm
159+
target: aarch64-unknown-linux-musl
160+
- os: macos-14
161+
target: aarch64-apple-darwin
162+
- os: windows-latest
163+
target: x86_64-pc-windows-msvc
164+
steps:
165+
- uses: actions/checkout@v4
166+
167+
- name: Download native binary
168+
uses: actions/download-artifact@v4
169+
with:
170+
name: bindings-${{ matrix.target }}
171+
path: napi
172+
173+
- name: Download generated JS bindings
174+
uses: actions/download-artifact@v4
175+
with:
176+
name: js-bindings
177+
path: napi
178+
179+
# musl binaries must load under a real musl libc, so run inside Alpine.
180+
- name: Run smoke test (Alpine)
181+
if: contains(matrix.target, 'musl')
182+
run: docker run --rm -v "$PWD:/repo" -w /repo/napi node:24-alpine node test.mjs
183+
184+
- name: Run smoke test
185+
if: ${{ !contains(matrix.target, 'musl') }}
186+
working-directory: napi
187+
run: node test.mjs
188+
115189
publish:
116190
name: Publish to npm
117-
needs: [check-version, build]
191+
needs: [check-version, build, smoke-test]
118192
runs-on: ubuntu-latest
119193
permissions:
120194
contents: read
@@ -154,9 +228,12 @@ jobs:
154228
node -e '
155229
const [suffix, version] = process.argv.slice(1)
156230
const meta = {
157-
"linux-x64-gnu": { os: ["linux"], cpu: ["x64"], libc: ["glibc"] },
158-
"darwin-arm64": { os: ["darwin"], cpu: ["arm64"] },
159-
"win32-x64-msvc": { os: ["win32"], cpu: ["x64"] },
231+
"linux-x64-gnu": { os: ["linux"], cpu: ["x64"], libc: ["glibc"] },
232+
"linux-x64-musl": { os: ["linux"], cpu: ["x64"], libc: ["musl"] },
233+
"linux-arm64-gnu": { os: ["linux"], cpu: ["arm64"], libc: ["glibc"] },
234+
"linux-arm64-musl": { os: ["linux"], cpu: ["arm64"], libc: ["musl"] },
235+
"darwin-arm64": { os: ["darwin"], cpu: ["arm64"] },
236+
"win32-x64-msvc": { os: ["win32"], cpu: ["x64"] },
160237
}[suffix]
161238
if (!meta) {
162239
console.error(`unknown platform suffix: ${suffix} — add it to the meta map`)

napi/Cargo.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

napi/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ npm install @firecrawl/pdf-inspector
3434
bun add @firecrawl/pdf-inspector
3535
```
3636

37-
Prebuilt binaries for **Linux x64**, **macOS ARM64**, and **Windows x64** — npm installs only the one matching your platform. No Rust toolchain needed.
37+
Prebuilt binaries for **Linux x64/ARM64** (glibc and musl/Alpine), **macOS ARM64**, and **Windows x64** — npm installs only the one matching your platform. No Rust toolchain needed.
3838

3939
## API
4040

@@ -116,9 +116,12 @@ Prebuilt binaries ship as platform-specific packages installed automatically via
116116

117117
| Platform | Architecture | Package |
118118
|----------|-------------|---------|
119-
| Linux | x64 (glibc) | `@firecrawl/pdf-inspector-linux-x64-gnu` |
120-
| macOS | ARM64 | `@firecrawl/pdf-inspector-darwin-arm64` |
121-
| Windows | x64 | `@firecrawl/pdf-inspector-win32-x64-msvc` |
119+
| Linux | x64 (glibc) | `@firecrawl/pdf-inspector-linux-x64-gnu` |
120+
| Linux | x64 (musl/Alpine) | `@firecrawl/pdf-inspector-linux-x64-musl` |
121+
| Linux | ARM64 (glibc) | `@firecrawl/pdf-inspector-linux-arm64-gnu` |
122+
| Linux | ARM64 (musl/Alpine) | `@firecrawl/pdf-inspector-linux-arm64-musl` |
123+
| macOS | ARM64 | `@firecrawl/pdf-inspector-darwin-arm64` |
124+
| Windows | x64 | `@firecrawl/pdf-inspector-win32-x64-msvc` |
122125

123126
## License
124127

napi/bun.lock

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

napi/package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@firecrawl/pdf-inspector",
3-
"version": "1.11.2",
3+
"version": "1.12.0",
44
"description": "Fast PDF classification and text extraction. Detect text-based vs scanned PDFs, extract text by region with quality checks. Native Rust performance via napi-rs.",
55
"main": "index.js",
66
"types": "index.d.ts",
@@ -37,6 +37,9 @@
3737
"binaryName": "pdf-inspector",
3838
"targets": [
3939
"x86_64-unknown-linux-gnu",
40+
"x86_64-unknown-linux-musl",
41+
"aarch64-unknown-linux-gnu",
42+
"aarch64-unknown-linux-musl",
4043
"aarch64-apple-darwin",
4144
"x86_64-pc-windows-msvc"
4245
]
@@ -49,8 +52,11 @@
4952
"@napi-rs/cli": "^3.4.1"
5053
},
5154
"optionalDependencies": {
52-
"@firecrawl/pdf-inspector-linux-x64-gnu": "1.11.2",
53-
"@firecrawl/pdf-inspector-darwin-arm64": "1.11.2",
54-
"@firecrawl/pdf-inspector-win32-x64-msvc": "1.11.2"
55+
"@firecrawl/pdf-inspector-linux-x64-gnu": "1.12.0",
56+
"@firecrawl/pdf-inspector-linux-x64-musl": "1.12.0",
57+
"@firecrawl/pdf-inspector-linux-arm64-gnu": "1.12.0",
58+
"@firecrawl/pdf-inspector-linux-arm64-musl": "1.12.0",
59+
"@firecrawl/pdf-inspector-darwin-arm64": "1.12.0",
60+
"@firecrawl/pdf-inspector-win32-x64-msvc": "1.12.0"
5561
}
5662
}

0 commit comments

Comments
 (0)