From 1e638392b683ac43449a5a8fd9275cf61a188ba5 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Sat, 16 May 2026 13:50:29 -0700 Subject: [PATCH 1/2] fix: statically link prebuilt Linux binaries against musl Fixes #300 --- .github/workflows/release-prebuilt-npm.yml | 4 ++++ scripts/build-bin.ts | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-prebuilt-npm.yml b/.github/workflows/release-prebuilt-npm.yml index 6077f0a7..f1d7a751 100644 --- a/.github/workflows/release-prebuilt-npm.yml +++ b/.github/workflows/release-prebuilt-npm.yml @@ -98,8 +98,10 @@ jobs: include: - package_name: hunkdiff-linux-arm64 runner: ubuntu-24.04-arm + target_triple: bun-linux-arm64-musl - package_name: hunkdiff-linux-x64 runner: ubuntu-latest + target_triple: bun-linux-x64-musl - package_name: hunkdiff-windows-x64 runner: windows-latest - package_name: hunkdiff-darwin-x64 @@ -119,6 +121,8 @@ jobs: run: bun install --frozen-lockfile - name: Build host artifact + env: + HUNK_TARGET_TRIPLE: ${{ matrix.target_triple }} run: | bun run build:bin bun run ./scripts/build-prebuilt-artifact.ts --expect-package "${{ matrix.package_name }}" diff --git a/scripts/build-bin.ts b/scripts/build-bin.ts index 2d26ca7f..b65fe041 100644 --- a/scripts/build-bin.ts +++ b/scripts/build-bin.ts @@ -12,16 +12,15 @@ const legacyOutfile = path.join(distDir, process.platform === "win32" ? "otdiff. mkdirSync(distDir, { recursive: true }); rmSync(legacyOutfile, { force: true }); +const buildArgs = ["bun", "build", "--compile", "--no-compile-autoload-bunfig"]; +const targetTriple = process.env.HUNK_TARGET_TRIPLE; +if (targetTriple) { + buildArgs.push("--target", targetTriple); +} +buildArgs.push(path.join(repoRoot, "src", "main.tsx"), "--outfile", outfile); + const proc = Bun.spawnSync( - [ - "bun", - "build", - "--compile", - "--no-compile-autoload-bunfig", - path.join(repoRoot, "src", "main.tsx"), - "--outfile", - outfile, - ], + buildArgs, { cwd: repoRoot, stdin: "inherit", From 19ef0973052fecc0152e27a0781effd9eb1ac603 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 9 Jul 2026 21:02:33 -0700 Subject: [PATCH 2/2] style: format build-bin.ts with oxfmt --- scripts/build-bin.ts | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/scripts/build-bin.ts b/scripts/build-bin.ts index b65fe041..9053e516 100644 --- a/scripts/build-bin.ts +++ b/scripts/build-bin.ts @@ -19,20 +19,17 @@ if (targetTriple) { } buildArgs.push(path.join(repoRoot, "src", "main.tsx"), "--outfile", outfile); -const proc = Bun.spawnSync( - buildArgs, - { - cwd: repoRoot, - stdin: "inherit", - stdout: "inherit", - stderr: "inherit", - env: { - ...process.env, - BUN_TMPDIR: path.join(repoRoot, ".bun-tmp"), - BUN_INSTALL: path.join(repoRoot, ".bun-install"), - }, +const proc = Bun.spawnSync(buildArgs, { + cwd: repoRoot, + stdin: "inherit", + stdout: "inherit", + stderr: "inherit", + env: { + ...process.env, + BUN_TMPDIR: path.join(repoRoot, ".bun-tmp"), + BUN_INSTALL: path.join(repoRoot, ".bun-install"), }, -); +}); if (proc.exitCode !== 0) { throw new Error(`bun build --compile failed with exit ${proc.exitCode}`);