Skip to content

Commit 14b2c98

Browse files
authored
fix: ship Windows and Linux native CLI binaries (#84)
1 parent 8baf103 commit 14b2c98

4 files changed

Lines changed: 55 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ jobs:
152152
if: ${{ steps.meta.outputs.kind == 'npm-cli' }}
153153
uses: dtolnay/rust-toolchain@stable
154154
with:
155-
targets: aarch64-apple-darwin,x86_64-apple-darwin
155+
targets: aarch64-apple-darwin,x86_64-apple-darwin,x86_64-unknown-linux-gnu,x86_64-pc-windows-gnu
156156

157157
- name: Install native build dependencies
158158
if: ${{ steps.meta.outputs.kind == 'npm-cli' }}
159-
run: brew install pkg-config x264
159+
run: brew install pkg-config x264 mingw-w64
160160

161161
- name: Install root dependencies
162162
run: npm ci
@@ -265,7 +265,7 @@ jobs:
265265
266266
# ---------- Build (kind-specific) ----------
267267

268-
- name: Build root simdeck (macOS arm64+x64 binaries + client + simdeck-test)
268+
- name: Build root simdeck (macOS + Linux + Windows native artifacts + client + simdeck-test)
269269
if: ${{ steps.meta.outputs.kind == 'npm-cli' }}
270270
run: |
271271
SIMDECK_BUILD_TARGET=aarch64-apple-darwin npm run build:cli
@@ -279,20 +279,31 @@ jobs:
279279
build/simdeck-bin-darwin-arm64 \
280280
build/simdeck-bin-darwin-x64
281281
282+
SIMDECK_DISABLE_X264=1 SIMDECK_BUILD_TARGET=x86_64-unknown-linux-gnu npm run build:cli
283+
cp build/simdeck-bin build/simdeck-bin-linux-x64
284+
285+
SIMDECK_DISABLE_X264=1 SIMDECK_BUILD_TARGET=x86_64-pc-windows-gnu npm run build:cli
286+
cp build/simdeck-bin.exe build/simdeck-bin-win32-x64.exe
287+
282288
npm run build:client
283289
npm run build:simdeck-test
284290
285-
- name: Verify CLI artifacts are macOS arm64+x64 binaries
291+
- name: Verify CLI artifacts are published for all supported hosts
286292
if: ${{ steps.meta.outputs.kind == 'npm-cli' }}
287293
run: |
288294
test -x build/simdeck-bin
289295
test -x build/simdeck-bin-darwin-arm64
290296
test -x build/simdeck-bin-darwin-x64
297+
test -x build/simdeck-bin-linux-x64
298+
test -x build/simdeck-bin-win32-x64.exe
299+
291300
file build/simdeck-bin
292301
file build/simdeck-bin | grep -q 'arm64'
293302
file build/simdeck-bin | grep -q 'x86_64'
294303
file build/simdeck-bin-darwin-arm64 | grep -q 'arm64'
295304
file build/simdeck-bin-darwin-x64 | grep -q 'x86_64'
305+
file build/simdeck-bin-linux-x64 | grep -q 'ELF'
306+
file build/simdeck-bin-win32-x64.exe | grep -Eq 'PE32|PE32\+'
296307
297308
# ---------- Apple codesign + notarize (root simdeck only) ----------
298309

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"scripts/studio-provider-bridge.mjs",
2020
"scripts/postinstall.mjs",
2121
"build/simdeck-bin",
22+
"build/simdeck-bin.exe",
2223
"build/camera/",
2324
"build/simdeck-bin-darwin-arm64",
2425
"build/simdeck-bin-darwin-x64",

packages/cli/bin/simdeck.mjs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,21 @@ if (!existsSync(binaryPath)) {
2929

3030
function findPackageRoot(startDir) {
3131
let current = path.resolve(startDir);
32+
const buildMarkers = [
33+
"simdeck-bin",
34+
"simdeck-bin.exe",
35+
"simdeck-bin-darwin-arm64",
36+
"simdeck-bin-darwin-x64",
37+
"simdeck-bin-linux-arm64",
38+
"simdeck-bin-linux-x64",
39+
"simdeck-bin-win32-x64.exe",
40+
];
41+
3242
while (true) {
33-
if (existsSync(path.join(current, "build", "simdeck-bin"))) {
43+
if (
44+
existsSync(path.join(current, "package.json")) ||
45+
buildMarkers.some((marker) => existsSync(path.join(current, "build", marker)))
46+
) {
3447
return current;
3548
}
3649
const parent = path.dirname(current);
@@ -57,18 +70,21 @@ function resolveBinaryPath(rootDir) {
5770
return null;
5871
}
5972

60-
const platformBinaryPath = path.join(rootDir, "build", binary);
61-
if (existsSync(platformBinaryPath)) {
62-
return platformBinaryPath;
63-
}
64-
65-
for (const fallback of ["simdeck-bin.exe", "simdeck-bin"]) {
66-
const fallbackBinaryPath = path.join(rootDir, "build", fallback);
67-
if (existsSync(fallbackBinaryPath)) {
68-
return fallbackBinaryPath;
73+
const candidateNames = [
74+
binary,
75+
"simdeck-bin.exe",
76+
"simdeck-bin",
77+
...Object.values(binaryByHost),
78+
];
79+
80+
for (const candidate of candidateNames) {
81+
const candidatePath = path.join(rootDir, "build", candidate);
82+
if (existsSync(candidatePath)) {
83+
return candidatePath;
6984
}
7085
}
71-
return platformBinaryPath;
86+
87+
return path.join(rootDir, "build", binary);
7288
}
7389

7490
let child;

scripts/github-actions.test.mjs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const ciWorkflow = readFileSync(
2525
new URL("../.github/workflows/ci.yml", import.meta.url),
2626
"utf8",
2727
);
28+
const releaseWorkflow = readFileSync(
29+
new URL("../.github/workflows/release.yml", import.meta.url),
30+
"utf8",
31+
);
2832
const packageJson = JSON.parse(
2933
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
3034
);
@@ -65,6 +69,14 @@ test("npm CLI wrapper resolves Windows x64 native binary", () => {
6569
assert.match(cliWrapper, /simdeck-bin-win32-x64\.exe/);
6670
});
6771

72+
test("release workflow builds all supported native CLI artifacts", () => {
73+
assert.match(releaseWorkflow, /x86_64-pc-windows-gnu/);
74+
assert.match(releaseWorkflow, /simdeck-bin-win32-x64\.exe/);
75+
assert.match(releaseWorkflow, /x86_64-unknown-linux-gnu/);
76+
assert.match(releaseWorkflow, /simdeck-bin-linux-x64/);
77+
assert.match(releaseWorkflow, /mingw-w64/);
78+
});
79+
6880
test("CI runs Android emulator integration on Linux and Windows", () => {
6981
assert.match(ciWorkflow, /integration-android:/);
7082
assert.match(ciWorkflow, /os:\s*\[\s*ubuntu-latest,\s*windows-latest\s*\]/);

0 commit comments

Comments
 (0)