Skip to content

Commit 06a08f7

Browse files
committed
fix: use native runners for macOS builds to enable CGO
Previously, the workflow attempted cross-compilation for x86_64 builds on arm64 runners, which forced CGO_ENABLED=0. This broke SQLite support because mattn/go-sqlite3 requires CGO. Changes: - Use macos-13 (Intel) for x86_64 builds - Use macos-latest (Apple Silicon) for arm64 builds - Remove cross-compilation logic that hardcoded CGO_ENABLED=0 - Now CGO_ENABLED=1 from scripts/package-macos.sh is properly used This fixes the "go-sqlite3 requires cgo to work" error.
1 parent 907bbf0 commit 06a08f7

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

.github/workflows/build-desktop.yml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ concurrency:
3333

3434
jobs:
3535
build-macos:
36-
runs-on: macos-latest
3736
strategy:
3837
matrix:
39-
arch: [x86_64, arm64]
38+
include:
39+
- arch: x86_64
40+
runner: macos-13 # Intel runner
41+
- arch: arm64
42+
runner: macos-latest # Apple Silicon runner
43+
runs-on: ${{ matrix.runner }}
4044
steps:
4145
- name: Checkout
4246
uses: actions/checkout@v4
@@ -61,17 +65,17 @@ jobs:
6165
path: |
6266
~/.pub-cache
6367
frontend/.dart_tool
64-
key: ${{ runner.os }}-flutter-${{ hashFiles('frontend/pubspec.lock') }}
68+
key: ${{ runner.os }}-${{ matrix.arch }}-flutter-${{ hashFiles('frontend/pubspec.lock') }}
6569
restore-keys: |
66-
${{ runner.os }}-flutter-
70+
${{ runner.os }}-${{ matrix.arch }}-flutter-
6771
6872
- name: Cache Go modules
6973
uses: actions/cache@v4
7074
with:
7175
path: ~/go/pkg/mod
72-
key: ${{ runner.os }}-go-${{ hashFiles('go.sum') }}
76+
key: ${{ runner.os }}-${{ matrix.arch }}-go-${{ hashFiles('go.sum') }}
7377
restore-keys: |
74-
${{ runner.os }}-go-
78+
${{ runner.os }}-${{ matrix.arch }}-go-
7579
7680
- name: Flutter pub get
7781
working-directory: frontend
@@ -96,26 +100,10 @@ jobs:
96100
env:
97101
VERSION: ${{ steps.version.outputs.VERSION }}
98102
run: |
99-
# Override architecture for cross-compilation if needed
100-
if [ "${{ matrix.arch }}" = "x86_64" ] && [ "$(uname -m)" != "x86_64" ]; then
101-
echo "Cross-compiling for x86_64 on arm64 host"
102-
# Build Go binary for x86_64
103-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" \
104-
-o dist/server_darwin_amd64 ./cmd/network-debugger
105-
# Flutter currently doesn't support cross-compilation for macOS
106-
# So we skip x86_64 builds on arm64 runners
107-
echo "Skipping x86_64 Flutter build on arm64 runner"
108-
exit 0
109-
elif [ "${{ matrix.arch }}" = "arm64" ] && [ "$(uname -m)" != "arm64" ]; then
110-
echo "Cannot cross-compile arm64 on x86_64 runner"
111-
exit 0
112-
fi
113-
114103
chmod +x scripts/package-macos.sh
115104
./scripts/package-macos.sh
116105
117106
- name: Upload DMG artifact
118-
if: matrix.arch == runner.arch || matrix.arch == 'arm64' && runner.arch == 'ARM64'
119107
uses: actions/upload-artifact@v4
120108
with:
121109
name: macos-${{ matrix.arch }}-dmg

0 commit comments

Comments
 (0)