Skip to content

Commit ff963df

Browse files
committed
fix(quoteforge[dist]): ad-hoc sign darwin binaries for apple silicon
1 parent 90b7403 commit ff963df

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ jobs:
4949
- name: Install deps
5050
run: bun install --frozen-lockfile
5151

52+
- name: Install rcodesign (for ad-hoc darwin signing)
53+
if: startsWith(matrix.bun-target, 'bun-darwin-') && runner.os != 'macOS'
54+
shell: bash
55+
env:
56+
RCODESIGN_VERSION: "0.29.0"
57+
run: |
58+
set -e
59+
url="https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F${RCODESIGN_VERSION}/apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl.tar.gz"
60+
curl -fsSL "$url" | tar -xz
61+
sudo mv "apple-codesign-${RCODESIGN_VERSION}-x86_64-unknown-linux-musl/rcodesign" /usr/local/bin/rcodesign
62+
rcodesign --version
63+
5264
- name: Build binary
5365
shell: bash
5466
env:

scripts/build-binaries.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ async function sha256(file: string): Promise<string> {
3434
return hash.digest("hex");
3535
}
3636

37+
async function adhocSignDarwin(binPath: string): Promise<void> {
38+
if (process.platform === "darwin") {
39+
await $`codesign --sign - --force ${binPath}`.quiet();
40+
return;
41+
}
42+
try {
43+
await $`rcodesign sign ${binPath}`.quiet();
44+
} catch {
45+
throw new Error(
46+
"rcodesign is required to ad-hoc sign darwin binaries from non-macOS hosts. " +
47+
"Install: https://github.com/indygreg/apple-platform-rs/releases (look for apple-codesign).",
48+
);
49+
}
50+
}
51+
3752
async function tarGz(binPath: string, archivePath: string, binName: string): Promise<void> {
3853
const cwd = resolve(binPath, "..");
3954
await $`tar -czf ${archivePath} -C ${cwd} ${binName}`;
@@ -57,6 +72,10 @@ async function buildOne(target: Target): Promise<{ archive: string; sha256: stri
5772
console.log(`→ ${target.bunTarget}`);
5873
await $`bun build ${ENTRY} --compile --minify --target=${target.bunTarget} --outfile=${binPath}`.quiet();
5974

75+
if (target.bunTarget.startsWith("bun-darwin-")) {
76+
await adhocSignDarwin(binPath);
77+
}
78+
6079
const archiveName = target.archive === "tar.gz"
6180
? `quoteforge-${target.triple}.tar.gz`
6281
: `quoteforge-${target.triple}.zip`;

0 commit comments

Comments
 (0)