Skip to content

Commit 8237365

Browse files
committed
refactor: replace Bun.build with fossilize for Node SEA binaries
- Replace Bun.build({ compile: true }) with fossilize --no-bundle - Switch esbuild output from ESM to CJS (Node SEA requirement) - Add import-meta-url.js shim for CJS format - Target node22 to downlevel 'using' declarations - Embed Ink sidecar via fossilize --assets + node:sea.getAsset() - Update text-import-plugin: file imports return path string (no ESM external) - Drop musl targets (Node doesn't publish musl binaries) - Remove bun:sqlite fallback from sqlite.ts (Node-only now) - Remove setup-bun from CI, add rcodesign for macOS signing - Remove Bun global from biome.jsonc - Suppress SQLite ExperimentalWarning in bin.ts - Add dist-build/ to .gitignore and biome excludes
1 parent 82779e8 commit 8237365

10 files changed

Lines changed: 488 additions & 275 deletions

File tree

.github/workflows/ci.yml

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,18 @@ jobs:
7575
{
7676
echo 'matrix<<MATRIX_EOF'
7777
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
78-
# PRs build linux-x64 (smoke test + e2e) and linux-x64-musl (Alpine smoke test)
78+
# PRs build linux-x64 (smoke test + e2e)
7979
echo '{"include":[
80-
{"target":"linux-x64", "os":"ubuntu-latest", "can-test":true},
81-
{"target":"linux-x64-musl", "os":"ubuntu-latest", "can-test":false}
80+
{"target":"linux-x64", "os":"ubuntu-latest", "can-test":true}
8281
]}'
8382
else
8483
# main, release/**, workflow_call: full cross-platform matrix
8584
echo '{"include":[
86-
{"target":"darwin-arm64", "os":"macos-latest", "can-test":true},
87-
{"target":"linux-x64", "os":"ubuntu-latest", "can-test":true},
88-
{"target":"linux-x64-musl", "os":"ubuntu-latest", "can-test":false},
89-
{"target":"windows-x64", "os":"windows-latest","can-test":true},
90-
{"target":"darwin-x64", "os":"macos-latest", "can-test":false},
91-
{"target":"linux-arm64", "os":"ubuntu-latest", "can-test":false},
92-
{"target":"linux-arm64-musl", "os":"ubuntu-latest", "can-test":false}
85+
{"target":"darwin-arm64", "os":"macos-latest", "can-test":true},
86+
{"target":"linux-x64", "os":"ubuntu-latest", "can-test":true},
87+
{"target":"windows-x64", "os":"windows-latest","can-test":true},
88+
{"target":"darwin-x64", "os":"macos-latest", "can-test":false},
89+
{"target":"linux-arm64", "os":"ubuntu-latest", "can-test":false}
9390
]}'
9491
fi
9592
echo 'MATRIX_EOF'
@@ -246,9 +243,6 @@ jobs:
246243
matrix: ${{ fromJSON(needs.changes.outputs.build-targets) }}
247244
steps:
248245
- uses: actions/checkout@v6
249-
- uses: oven-sh/setup-bun@v2
250-
with:
251-
bun-version: "1.3.13"
252246
- uses: pnpm/action-setup@v4
253247
- uses: actions/setup-node@v6
254248
with:
@@ -262,6 +256,28 @@ jobs:
262256
if: steps.cache.outputs.cache-hit != 'true'
263257
shell: bash
264258
run: pnpm install --frozen-lockfile
259+
- name: Setup codesign dependencies
260+
env:
261+
APPLE_CERT_DATA: ${{ secrets.CSC_LINK }}
262+
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
263+
run: |
264+
curl -L 'https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz' -o 'rcodesign.tar.gz'
265+
echo 'dbe85cedd8ee4217b64e9a0e4c2aef92ab8bcaaa41f20bde99781ff02e600002 rcodesign.tar.gz' | sha256sum -c
266+
tar -xzf rcodesign.tar.gz --strip-components=1
267+
mv rcodesign /usr/local/bin/rcodesign
268+
rm rcodesign.tar.gz
269+
if [ -n "$APPLE_CERT_DATA" ]; then
270+
echo "$APPLE_CERT_DATA" | base64 --decode > /tmp/certs.p12
271+
echo 'APPLE_CERT_PATH=/tmp/certs.p12' >> $GITHUB_ENV
272+
fi
273+
if [ -n "$APPLE_API_KEY" ]; then
274+
echo "$APPLE_API_KEY" | base64 -d > /tmp/apple_key.json
275+
cat /tmp/apple_key.json | jq .private_key -r > /tmp/apple_key.pem
276+
echo "APPLE_API_KEY_ISSUER_ID=$(cat /tmp/apple_key.json | jq .issuer_id -r | tr -d '\n\r')" >> $GITHUB_ENV
277+
echo "APPLE_API_KEY_ID=$(cat /tmp/apple_key.json | jq .key_id -r | tr -d '\n\r')" >> $GITHUB_ENV
278+
echo "APPLE_API_KEY_P8_PATH=/tmp/apple_key.pem" >> $GITHUB_ENV
279+
echo 'APPLE_API_KEY_PATH=/tmp/apple_key.json' >> $GITHUB_ENV
280+
fi
265281
- name: Set nightly version
266282
# Inject the nightly version (computed once in the changes job) into
267283
# package.json before the build so it gets baked into the binary.
@@ -278,7 +294,11 @@ jobs:
278294
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
279295
# Set on main/release branches so build.ts runs binpunch + creates .gz
280296
RELEASE_BUILD: ${{ github.event_name != 'pull_request' && '1' || '' }}
281-
run: bun run build --target ${{ matrix.target }}
297+
# Codesigning: only on main/release pushes (fork PRs lack secrets)
298+
FOSSILIZE_SIGN: ${{ github.event_name == 'push' && (github.ref_name == 'main' || startsWith(github.ref_name, 'release/')) && 'y' || 'n' }}
299+
APPLE_CERT_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
300+
APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
301+
run: pnpm run build -- --target ${{ matrix.target }}
282302
- name: Smoke test
283303
if: matrix.can-test
284304
shell: bash
@@ -288,11 +308,6 @@ jobs:
288308
else
289309
./dist-bin/sentry-${{ matrix.target }} --help
290310
fi
291-
- name: Smoke test (musl/Alpine)
292-
if: matrix.target == 'linux-x64-musl'
293-
run: |
294-
docker run --rm -v "$PWD/dist-bin:/dist-bin:ro" alpine:latest \
295-
sh -c "apk add --no-cache libstdc++ libgcc >/dev/null 2>&1 && /dist-bin/sentry-linux-x64-musl --help"
296311
- name: Upload binary artifact
297312
uses: actions/upload-artifact@v7
298313
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package-lock.json
66
out
77
dist
88
dist-bin
9+
dist-build
910
*.tgz
1011

1112
# fossilize build cache

biome.jsonc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
// custom-ca.ts excluded: Biome's type analysis hits the 200k type limit
1414
// on the node:tls module graph — an internal Biome bug that surfaces
1515
// non-deterministically as error vs warning. See biome issue tracker.
16-
"includes": ["!docs", "!test/init-eval/templates", "!!src/lib/custom-ca.ts"]
17-
},
18-
"javascript": {
19-
"globals": ["Bun"]
16+
"includes": [
17+
"!docs",
18+
"!test/init-eval/templates",
19+
"!dist-build",
20+
"!!src/lib/custom-ca.ts"
21+
]
2022
},
23+
"javascript": {},
2124
"linter": {
2225
"rules": {
2326
"style": {

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"consola": "^3.4.2",
3333
"esbuild": "^0.25.0",
3434
"fast-check": "^4.5.3",
35+
"fossilize": "^0.5.0",
3536
"hono": "^4.12.15",
3637
"http-cache-semantics": "^4.2.0",
3738
"ignore": "^7.0.5",
@@ -92,8 +93,8 @@
9293
"tsx": "tsx --import ./script/require-shim.mjs",
9394
"cli": "pnpm tsx src/bin.ts",
9495
"dev": "pnpm run generate:schema && pnpm run generate:docs && pnpm run generate:sdk && pnpm tsx src/bin.ts",
95-
"build": "pnpm run generate:schema && pnpm run generate:docs && pnpm run generate:sdk && bun run script/build.ts --single",
96-
"build:all": "pnpm run generate:schema && pnpm run generate:docs && pnpm run generate:sdk && bun run script/build.ts",
96+
"build": "pnpm run generate:schema && pnpm run generate:docs && pnpm run generate:sdk && pnpm tsx script/build.ts --single",
97+
"build:all": "pnpm run generate:schema && pnpm run generate:docs && pnpm run generate:sdk && pnpm tsx script/build.ts",
9798
"bundle": "pnpm run generate:schema && pnpm run generate:docs && pnpm run generate:sdk && pnpm tsx script/bundle.ts",
9899
"typecheck": "pnpm run generate:docs && pnpm run generate:sdk && tsc --noEmit",
99100
"lint": "biome check --no-errors-on-unmatched --max-diagnostics=none ./",

0 commit comments

Comments
 (0)