From b8a9bbcf3d7362e107a3c9b2d85b3b3e40fbf42b Mon Sep 17 00:00:00 2001 From: linonetwo Date: Mon, 8 Dec 2025 14:01:38 +0800 Subject: [PATCH] fix: macos intel build --- .github/workflows/release.yml | 6 ++++- docs/Release.md | 43 +++++++++++++++++++++++++++++++++++ package.json | 2 +- scripts/afterPack.ts | 5 +--- 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 docs/Release.md diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e1a884a3..07a4f8ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,9 +35,13 @@ jobs: - os: ubuntu-latest platform: linux arch: arm64 - - os: macos-latest + # Use macos-13 (Intel) for x64 builds to get correct dugite git binaries + # Note: macos-13 is deprecated but macos-15-large (Intel) requires paid plan + # When macos-13 is fully deprecated, switch to macos-15-large or use cross-compilation workaround + - os: macos-13 platform: mac arch: x64 + # Use macos-latest (ARM64) for arm64 builds - os: macos-latest platform: mac arch: arm64 diff --git a/docs/Release.md b/docs/Release.md new file mode 100644 index 00000000..7ea37959 --- /dev/null +++ b/docs/Release.md @@ -0,0 +1,43 @@ +# Release App + +See [.github/workflows/release.yml](.github/workflows/release.yml) + +## macOS Runner Architecture Mismatch Issue + +If you build x64 version on an ARM64 runner, dugite will download ARM64 git binaries. When users run the x64 app on Intel Mac, it fails with error: `spawn Unknown system error -86 (EBADEXEC)`. + +Solution: Use architecture-specific runners: + +- Use `macos-13` for x64 builds (free) +- Use `macos-latest` for arm64 builds (free) + +See `.github/workflows/release.yml` matrix configuration. + +### Future: When macos-13 is Deprecated + +When GitHub fully deprecates `macos-13`, you have two options: + +Option A (Simple, Costs Money): +Replace `macos-13` with `macos-15-large` in release.yml. Note that `-large` runners require GitHub Team or Enterprise plan and incur charges even for public repos. + +Option B (Complex, Free): +Use npm_config_arch environment variable to force dugite download correct architecture on ARM64 runner: + +```yaml +- name: Install dependencies + run: pnpm install + env: + npm_config_arch: ${{ matrix.arch }} +``` + +This tells dugite's postinstall script which architecture to download, regardless of host machine. See `node_modules/dugite/script/config.js` for details. + +## App Size Reduction + +dugite bundles a full git distribution. The package contains unnecessary components for TidGi: + +- 141 git command symlinks (all point to main git binary, only needed if directly invoking `git-add` instead of `git add`) +- Git LFS (13MB, TiddlyWiki wikis don't use LFS) +- Git Credential Manager + .NET runtime (26MB on macOS, TidGi embeds credentials directly in URLs) + +afterPack script automatically removes these, saving approximately 40-60MB per platform. See `scripts/trimDugite.ts` for implementation details. diff --git a/package.json b/package.json index 2f93a81f..f4aeee26 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "tidgi", "productName": "TidGi", "description": "Customizable personal knowledge-base with Github as unlimited storage and blogging platform.", - "version": "0.13.0-prerelease15", + "version": "0.13.0-prerelease16", "license": "MPL 2.0", "packageManager": "pnpm@10.24.0", "scripts": { diff --git a/scripts/afterPack.ts b/scripts/afterPack.ts index c514c2ed..0167ef8f 100644 --- a/scripts/afterPack.ts +++ b/scripts/afterPack.ts @@ -5,7 +5,6 @@ */ import fs from 'fs-extra'; import path from 'path'; -import { trimUnusedGitCommands } from './trimDugite'; /** * Running afterPack hook @@ -83,13 +82,11 @@ export default ( console.log('Copy dugite'); // it has things like `git/bin/libexec/git-core/git-add` link to `git/bin/libexec/git-core/git`, to reduce size, so can't use `dereference: true, recursive: true` here. - const dugiteDestination = path.join(cwd, 'node_modules', 'dugite'); fs.copySync( path.join(sourceNodeModulesFolder, 'dugite'), - dugiteDestination, + path.join(cwd, 'node_modules', 'dugite'), { dereference: false }, ); - trimUnusedGitCommands(dugiteDestination, platform); if (platform === 'win32') { console.log('Copy registry-js (Windows only)');