Skip to content

Commit ba5e1f0

Browse files
committed
Add macOS build workflow
- Add GitHub Actions workflow for building macOS universal binary - Update Cargo.lock with dependencies - Configure workflow with code signing and notarization support - Support both x86_64 and aarch64 architectures
1 parent efbeffc commit ba5e1f0

2 files changed

Lines changed: 159 additions & 0 deletions

File tree

.github/workflows/build-macos.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Build macOS
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main, test-macos-workflow]
7+
8+
jobs:
9+
build:
10+
name: Build macOS Universal
11+
runs-on: macos-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Rust
17+
uses: dtolnay/rust-toolchain@stable
18+
with:
19+
targets: aarch64-apple-darwin,x86_64-apple-darwin
20+
21+
- name: Setup Rust cache
22+
uses: Swatinem/rust-cache@v2
23+
with:
24+
workspaces: src-tauri
25+
26+
- name: Setup Bun
27+
uses: oven-sh/setup-bun@v2
28+
29+
- name: Install dependencies
30+
run: bun install
31+
32+
- name: Import Apple certificates
33+
env:
34+
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
35+
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
36+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
37+
run: |
38+
# Create variables
39+
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
40+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
41+
42+
# Import certificate from secrets
43+
echo -n "$APPLE_CERTIFICATE" | base64 --decode -o $CERTIFICATE_PATH
44+
45+
# Create temporary keychain
46+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
47+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
48+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
49+
50+
# Import certificate to keychain
51+
security import $CERTIFICATE_PATH -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
52+
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
53+
security list-keychain -d user -s $KEYCHAIN_PATH
54+
55+
- name: Build for ARM64
56+
run: bun run tauri build -- --target aarch64-apple-darwin
57+
58+
- name: Build for x86_64
59+
run: bun run tauri build -- --target x86_64-apple-darwin
60+
61+
- name: Create universal binary
62+
run: |
63+
mkdir -p src-tauri/target/universal-apple-darwin/release
64+
lipo -create -output src-tauri/target/universal-apple-darwin/release/claudia \
65+
src-tauri/target/aarch64-apple-darwin/release/claudia \
66+
src-tauri/target/x86_64-apple-darwin/release/claudia
67+
68+
echo "✅ Universal binary created"
69+
lipo -info src-tauri/target/universal-apple-darwin/release/claudia
70+
71+
- name: Prepare app bundle with universal binary
72+
run: |
73+
# Create temp directory
74+
mkdir -p dmg_temp
75+
76+
# Copy the app bundle from one of the builds
77+
cp -R src-tauri/target/release/bundle/macos/Claudia.app dmg_temp/
78+
79+
# Replace the binary with universal binary
80+
rm -f dmg_temp/Claudia.app/Contents/MacOS/claudia
81+
cp src-tauri/target/universal-apple-darwin/release/claudia dmg_temp/Claudia.app/Contents/MacOS/claudia
82+
83+
- name: Sign app bundle
84+
env:
85+
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
86+
run: |
87+
codesign --sign "$APPLE_SIGNING_IDENTITY" \
88+
--timestamp \
89+
--options runtime \
90+
--force \
91+
--deep \
92+
--entitlements src-tauri/entitlements.plist \
93+
dmg_temp/Claudia.app
94+
95+
- name: Create DMG
96+
run: |
97+
hdiutil create -volname "Claudia Installer" \
98+
-srcfolder dmg_temp \
99+
-ov -format UDZO Claudia.dmg
100+
101+
- name: Sign DMG
102+
env:
103+
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
104+
run: |
105+
codesign --sign "$APPLE_SIGNING_IDENTITY" \
106+
--timestamp \
107+
--force Claudia.dmg
108+
109+
- name: Notarize DMG
110+
env:
111+
APPLE_ID: ${{ secrets.APPLE_ID }}
112+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
113+
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
114+
run: |
115+
# Store notarization credentials
116+
xcrun notarytool store-credentials "notarytool-profile" \
117+
--apple-id "$APPLE_ID" \
118+
--team-id "$APPLE_TEAM_ID" \
119+
--password "$APPLE_PASSWORD"
120+
121+
# Submit for notarization
122+
xcrun notarytool submit Claudia.dmg \
123+
--keychain-profile "notarytool-profile" \
124+
--wait
125+
126+
- name: Staple notarization
127+
run: xcrun stapler staple Claudia.dmg
128+
129+
- name: Verify DMG
130+
run: |
131+
spctl -a -t open -vvv --context context:primary-signature Claudia.dmg
132+
echo "✅ DMG verification complete"
133+
134+
- name: Create artifacts directory
135+
run: |
136+
mkdir -p dist/macos-universal
137+
cp Claudia.dmg dist/macos-universal/
138+
139+
# Also save the app bundle
140+
cd dmg_temp && zip -r ../dist/macos-universal/Claudia.app.zip Claudia.app && cd ..
141+
142+
# Generate checksum
143+
shasum -a 256 dist/macos-universal/* > dist/macos-universal/checksums.txt
144+
145+
- name: Upload artifacts
146+
uses: actions/upload-artifact@v4
147+
with:
148+
name: macos-universal
149+
path: dist/macos-universal/*

src-tauri/Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)