Skip to content

fix(release): ship both macOS arm64 and x64 DMGs with correct native modules (#176)#185

Merged
hqhq1025 merged 1 commit intomainfrom
fix/release-mac-dual-arch-176
Apr 23, 2026
Merged

fix(release): ship both macOS arm64 and x64 DMGs with correct native modules (#176)#185
hqhq1025 merged 1 commit intomainfrom
fix/release-mac-dual-arch-176

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

Summary

Closes #176.

v0.1.3 on macOS Intel fails to open the snapshots DB with:

dlopen(...better_sqlite3.node-electron.node): (mach-o file, but is an
incompatible architecture (have 'arm64', need 'x86_64'))

Diagnosis (scenario A)

  • electron-builder.yml already declares mac.target.arch: [arm64, x64], and the v0.1.3 release assets include both open-codesign-0.1.3-arm64.dmg and open-codesign-0.1.3-x64.dmg.
  • Both DMGs were produced on a single macos-latest (arm64) runner.
  • apps/desktop/scripts/install-sqlite-bindings.cjs stages per-arch prebuilds plus a legacy alias better_sqlite3.node-electron.node that points at the host arch. The runtime resolver in apps/desktop/src/main/snapshots-db.ts prefers arch-specific files and only falls back to the legacy alias when they are missing.
  • The user's dlopen trace loads the legacy alias — meaning the x64-specific file did not make it into the x64 DMG. electron-builder's per-arch packaging pass reuses host-arch bytes for files it does not know to re-stage, so the x64 DMG ships with arm64 bytes.

Fix

Split the macOS build into native-arch runners and pin electron-builder to each runner's host arch. Each runner does a fresh pnpm install, so our postinstall stages the correct per-arch binaries and the legacy alias matches the DMG arch.

  • macos-latest (Apple Silicon) builds --arm64open-codesign-*-arm64.dmg
  • macos-13 (Intel) builds --x64open-codesign-*-x64.dmg

Scope is limited to .github/workflows/release.yml. Runtime resolution code and electron-builder.yml are unchanged.

Principles check

  • Compatibility: green — no format / schema changes.
  • Upgradeability: green — future native-module additions inherit the native-runner guarantee.
  • No bloat: green — workflow only; one extra mac runner-minute per release.
  • Elegance: green — removes an implicit cross-build assumption.

Test plan

Cannot fully verify locally (needs the full release workflow + published artifacts). Required CI validation:

  • Tag a prerelease (e.g. v0.1.4-rc.1) or dispatch the Release workflow against a test tag.
  • Confirm matrix runs Build (macos-arm64) on macos-latest and Build (macos-x64) on macos-13, each finishing green.
  • Download both DMGs from the artifacts / release.
  • hdiutil attach open-codesign-*-x64.dmg and run lipo -archs 'Open CoDesign.app/Contents/Resources/app.asar.unpacked/node_modules/better-sqlite3/build/Release/better_sqlite3.node-electron.node' → expect x86_64.
  • Repeat on the arm64 DMG → expect arm64.
  • Launch x64 DMG on an Intel Mac (or VM): no "Could not open the local snapshots database" banner.

Local CI signal: pnpm lint and pnpm typecheck both green on this branch.

…lt native modules (#176)

The previous release workflow built both arm64 and x64 DMGs on a single
macos-latest (arm64) runner via electron-builder's mac.target.arch
list. Our install-sqlite-bindings.cjs postinstall stages per-arch
better-sqlite3 prebuilds plus a legacy alias pointing at the host arch,
but electron-builder's per-arch packaging pass reuses the host-arch
bytes for files it does not know to re-stage. The x64 DMG ended up
with an arm64 native module, so Intel Macs hit:

  dlopen(...better_sqlite3.node-electron.node): have 'arm64', need 'x86_64'

Split the macOS build into two native-arch runners (macos-latest for
arm64, macos-13 for x64) and pin electron-builder to the runner's host
arch (--arm64 / --x64). Each runner does a fresh pnpm install, so the
postinstall stages the correct per-arch binaries and the legacy alias
matches the DMG arch.

Signed-off-by: hqhq1025 <1506751656@qq.com>
@github-actions github-actions Bot added area:packaging Installers, signing, Linux deb/rpm area:build Turbo/Vite/Biome/tsconfig toolchain labels Apr 23, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • None. No high-confidence blocker/major/minor issues found in the added/modified lines of .github/workflows/release.yml.

Summary

  • Review mode: initial
  • No issues identified in this diff.
  • Residual risks/testing gaps: this workflow change cannot be fully validated from static review alone; the key risk is runtime packaging behavior on GitHub-hosted macOS runners (macos-latest arm64 and macos-13 x64).

Testing

  • Not run (automation).
  • Suggested validation:
    1. Run the release workflow on a test tag and verify both Build (macos-arm64) and Build (macos-x64) succeed.
    2. Inspect each DMG artifact and confirm better_sqlite3.node-electron.node architecture matches the DMG arch (arm64 vs x86_64).

open-codesign Bot

@hqhq1025 hqhq1025 merged commit c0149f7 into main Apr 23, 2026
8 checks passed
@hqhq1025 hqhq1025 deleted the fix/release-mac-dual-arch-176 branch April 23, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:build Turbo/Vite/Biome/tsconfig toolchain area:packaging Installers, signing, Linux deb/rpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: could not load local database

1 participant