-
Notifications
You must be signed in to change notification settings - Fork 9
359 lines (322 loc) · 14.6 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
name: "Build"
on:
workflow_call:
secrets:
APPLE_ID:
required: true
APPLE_ID_PASSWORD:
required: true
APPLE_TEAM_ID:
required: true
APPLE_CERTIFICATE:
required: true
APPLE_CERTIFICATE_PASSWORD:
required: true
KEYCHAIN_PASSWORD:
required: true
GPG_PRIVATE_KEY:
required: true
GPG_PASSPHRASE:
required: true
ANDROID_KEY_ALIAS:
required: true
ANDROID_KEY_PASSWORD:
required: true
ANDROID_KEY_BASE64:
required: true
pull_request:
push:
jobs:
build-tauri:
strategy:
fail-fast: false
matrix:
include:
# macOS desktop builds
- name: "macOS (Apple Silicon)"
platform: "macos-latest"
args: "--target aarch64-apple-darwin"
arch: "aarch64"
- name: "macOS (Intel)"
platform: "macos-latest"
args: "--target x86_64-apple-darwin"
arch: "x86_64"
# Linux desktop builds
- name: "Linux Desktop"
platform: "ubuntu-22.04"
args: ""
# Single Android build that will output all ABIs
- name: "Android"
platform: "ubuntu-22.04"
android: true
runs-on: ${{ matrix.platform }}
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
steps:
- uses: actions/checkout@v4
- name: Cache bun dependencies
uses: actions/cache@v4
with:
path: |
~/.bun/install/cache
node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.39
- name: Add Rust cache
uses: Swatinem/rust-cache@v2
with:
# Specify the working directory for Rust cache
workspaces: "src-tauri -> target"
# Cache cargo registry
cache-directories: |
~/.cargo/registry
~/.cargo/git
# Add a suffix to distinguish between different platforms and architectures
key: ${{ matrix.platform }}${{ matrix.arch && '-' }}${{ matrix.arch }}${{ matrix.android && '-android' }}
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: >-
${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
${{ matrix.android && 'aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android' || '' }}
- name: Install frontend dependencies
run: bun install
- name: Cache Android NDK
if: matrix.android
uses: actions/cache@v4
with:
path: /usr/local/lib/android/sdk/ndk/25.2.9519653
key: ${{ runner.os }}-ndk-25.2.9519653
- name: Set up JDK 17
if: matrix.android
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' && !matrix.android
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf \
libfuse2 fuse libglib2.0-dev libcairo2-dev libpango1.0-dev \
libasound2-dev libgtk-3-dev desktop-file-utils
- name: Setup Android SDK
if: matrix.android
uses: android-actions/setup-android@v3
- name: Install Android NDK
if: matrix.android
run: |
sdkmanager --install "ndk;25.2.9519653"
echo "ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/25.2.9519653" >> $GITHUB_ENV
echo "NDK_HOME=$ANDROID_SDK_ROOT/ndk/25.2.9519653" >> $GITHUB_ENV
- name: Import Apple Developer Certificate
if: matrix.platform == 'macos-latest'
id: import_apple_certificate
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
run: |
echo $APPLE_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-keychain-settings -t 3600 -l build.keychain
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
security list-keychains -s build.keychain
security list-keychains
security find-identity -v -p codesigning build.keychain
- name: Verify Certificate
if: matrix.platform == 'macos-latest'
id: verify_apple_certificate
run: |
security find-identity -v -p codesigning build.keychain
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep -E "Apple (Development|Distribution)")
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
echo "cert_id=$CERT_ID" >> "$GITHUB_OUTPUT"
echo "Apple Developer Certificate imported."
- name: Import GPG key
if: matrix.platform == 'ubuntu-22.04' && !matrix.android
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
trust_level: 5
- name: Setup Android signing
if: matrix.android
run: |
cd src-tauri/gen/android
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" > keystore.properties
echo "password=${{ secrets.ANDROID_KEY_PASSWORD }}" >> keystore.properties
base64 -d <<< "${{ secrets.ANDROID_KEY_BASE64 }}" > $RUNNER_TEMP/keystore.jks
echo "storeFile=$RUNNER_TEMP/keystore.jks" >> keystore.properties
# Split the build step into two different actions based on the target
- name: Build Desktop App
if: ${{ !matrix.android }}
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Apple signing
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ matrix.platform == 'macos-latest' && steps.verify_apple_certificate.outputs.cert_id || '' }}
# AppImage signing
LDAI_SIGN: ${{ matrix.platform == 'ubuntu-22.04' && !matrix.android }}
LDAI_SIGN_KEY: ${{ matrix.platform == 'ubuntu-22.04' && !matrix.android && steps.import_gpg.outputs.keyid || '' }}
LDAI_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
# DEB signing
TAURI_SIGNING_KEY: ${{ matrix.platform == 'ubuntu-22.04' && !matrix.android && steps.import_gpg.outputs.keyid || '' }}
TAURI_SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
# RPM signing
RPM_SIGNING_KEY: ${{ matrix.platform == 'ubuntu-22.04' && !matrix.android && steps.import_gpg.outputs.keyid || '' }}
RPM_SIGNING_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
with:
args: ${{ matrix.args }}
- name: Generate desktop artifact hashes
if: ${{ !matrix.android }}
run: |
if [ "${{ matrix.platform }}" = "ubuntu-22.04" ]; then
# Get version from Cargo.toml
VERSION=$(grep '^version[[:space:]]*=[[:space:]]*"' src-tauri/Cargo.toml | sed 's/^version[[:space:]]*=[[:space:]]*"\(.*\)"/\1/')
cd src-tauri/target/release/bundle
# Generate hash for each Linux package
find . -type f -name "*.deb" -exec sh -c '
sha256sum "$1" | sed "s| .*| whitenoise-${VERSION}-linux-amd64.deb|" > "${1}.sha256"
' sh {} \;
find . -type f -name "*.rpm" -exec sh -c '
sha256sum "$1" | sed "s| .*| whitenoise-${VERSION}-linux-x86_64.rpm|" > "${1}.sha256"
' sh {} \;
find . -type f -name "*.AppImage" -exec sh -c '
sha256sum "$1" | sed "s| .*| whitenoise-${VERSION}-linux-x86_64.AppImage|" > "${1}.sha256"
' sh {} \;
elif [ "${{ matrix.platform }}" = "macos-latest" ]; then
# Get version from Cargo.toml
VERSION=$(grep '^version[[:space:]]*=[[:space:]]*"' ../../../../src-tauri/Cargo.toml | sed 's/^version[[:space:]]*=[[:space:]]*"\(.*\)"/\1/')
cd src-tauri/target/${{ matrix.arch }}-apple-darwin/release/bundle
# Generate hash for macOS app bundle
cd macos
find . -type f -name "*.app" -exec sh -c '
shasum -a 256 "$1" | sed "s| .*| whitenoise-${VERSION}-macos-${{ matrix.arch }}.app|" > "${1}.sha256"
' sh {} \;
find . -type f -name "*.app.tar.gz" -exec sh -c '
shasum -a 256 "$1" | sed "s| .*| whitenoise-${VERSION}-macos-${{ matrix.arch }}.app.tar.gz|" > "${1}.sha256"
' sh {} \;
# Generate hash for DMG
cd ../dmg
find . -type f -name "*.dmg" -exec sh -c '
shasum -a 256 "$1" | sed "s| .*| whitenoise-${VERSION}-macos-${{ matrix.arch }}.dmg|" > "${1}.sha256"
' sh {} \;
fi
- name: Build Android universal binary
if: matrix.android
run: |
bun tauri android build
- name: Build Android arch specific binaries
if: matrix.android
run: |
bun tauri android build --apk --split-per-abi
- name: List Android build outputs
if: matrix.android
run: |
echo "Listing all APKs recursively:"
find src-tauri/gen/android -name "*.apk" -type f
echo "\nListing all AABs recursively:"
find src-tauri/gen/android -name "*.aab" -type f
echo "\nListing specific release directories:"
ls -la src-tauri/gen/android/app/build/outputs/apk/*/release/ || echo "Release dirs not found"
- name: Prepare Android artifacts
if: matrix.android
run: |
# Get version from Cargo.toml
VERSION=$(grep '^version[[:space:]]*=[[:space:]]*"' src-tauri/Cargo.toml | sed 's/^version[[:space:]]*=[[:space:]]*"\(.*\)"/\1/')
echo "Version: $VERSION"
mkdir -p android-artifacts
echo "Checking source paths:"
for type in universal arm64 arm x86 x86_64; do
echo "Checking ${type}:"
ls -la "src-tauri/gen/android/app/build/outputs/apk/${type}/release/" || echo "${type} directory not found"
done
# Copy files with error checking
for pair in \
"universal/release/app-universal-release.apk:android-universal.apk" \
"arm64/release/app-arm64-release.apk:android-arm64.apk" \
"arm/release/app-arm-release.apk:android-arm.apk" \
"x86/release/app-x86-release.apk:android-x86.apk" \
"x86_64/release/app-x86_64-release.apk:android-x86_64.apk"; do
src=${pair%:*}
dst=${pair#*:}
if [ -f "src-tauri/gen/android/app/build/outputs/apk/$src" ]; then
cp "src-tauri/gen/android/app/build/outputs/apk/$src" "android-artifacts/whitenoise-${VERSION}-${dst}"
echo "Copied $src successfully"
else
echo "Source file not found: $src"
fi
done
- name: Generate Android artifact hashes
if: matrix.android
run: |
cd android-artifacts
find . -type f -not -name "*.sha256" -exec sh -c '
sha256sum "$1" | sed "s|./| |" > "${1}.sha256"
' sh {} \;
- name: List Android artifacts
if: matrix.android
run: |
find android-artifacts/* -type f
- name: Upload Android artifacts
if: matrix.android
uses: actions/upload-artifact@v4
with:
name: android
path: android-artifacts/*
- name: Prepare Desktop artifacts
if: ${{ !matrix.android }}
run: |
# Get version from Cargo.toml
VERSION=$(grep '^version[[:space:]]*=[[:space:]]*"' src-tauri/Cargo.toml | sed 's/^version[[:space:]]*=[[:space:]]*"\(.*\)"/\1/')
echo "Version: $VERSION"
mkdir -p desktop-artifacts
if [ "${{ matrix.platform }}" = "ubuntu-22.04" ]; then
# Linux packages
find src-tauri/target/release/bundle/deb -name "*.deb" -exec sh -c '
cp "$1" desktop-artifacts/whitenoise-'"$VERSION"'-linux-amd64.deb
cp "${1}.sha256" desktop-artifacts/whitenoise-'"$VERSION"'-linux-amd64.deb.sha256
' sh {} \;
find src-tauri/target/release/bundle/rpm -name "*.rpm" -exec sh -c '
cp "$1" desktop-artifacts/whitenoise-'"$VERSION"'-linux-x86_64.rpm
cp "${1}.sha256" desktop-artifacts/whitenoise-'"$VERSION"'-linux-x86_64.rpm.sha256
' sh {} \;
find src-tauri/target/release/bundle/appimage -name "*.AppImage" -exec sh -c '
cp "$1" desktop-artifacts/whitenoise-'"$VERSION"'-linux-x86_64.AppImage
cp "${1}.sha256" desktop-artifacts/whitenoise-'"$VERSION"'-linux-x86_64.AppImage.sha256
' sh {} \;
elif [ "${{ matrix.platform }}" = "macos-latest" ]; then
# macOS packages
find src-tauri/target/${{ matrix.arch }}-apple-darwin/release/bundle/dmg -name "*.dmg" -exec sh -c '
cp "$1" desktop-artifacts/whitenoise-'"$VERSION"'-macos-${{ matrix.arch }}.dmg
cp "${1}.sha256" desktop-artifacts/whitenoise-'"$VERSION"'-macos-${{ matrix.arch }}.dmg.sha256
' sh {} \;
find src-tauri/target/${{ matrix.arch }}-apple-darwin/release/bundle/macos -name "*.app.tar.gz" -exec sh -c '
cp "$1" desktop-artifacts/whitenoise-'"$VERSION"'-macos-${{ matrix.arch }}.app.tar.gz
cp "${1}.sha256" desktop-artifacts/whitenoise-'"$VERSION"'-macos-${{ matrix.arch }}.app.tar.gz.sha256
' sh {} \;
fi
- name: List desktop artifacts
if: ${{ !matrix.android }}
run: |
find desktop-artifacts/* -type f
- name: Upload Desktop artifacts
if: ${{ !matrix.android }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}${{ matrix.arch && '-' }}${{ matrix.arch }}
path: desktop-artifacts/*