-
Notifications
You must be signed in to change notification settings - Fork 12
359 lines (307 loc) · 12.7 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:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install PNPM
uses: pnpm/action-setup@v4
- name: Install dependencies
run: pnpm install
- name: Prettier
run: pnpm prettier:check
- name: Install GTK
run: sudo apt-get update && sudo apt-get install libgtk-3-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev
- name: Clippy
run: cargo clippy --workspace --all-features --all-targets
- name: Test
run: cargo test --workspace --all-features
- name: Unused dependencies
run: |
cargo install cargo-machete --locked
cargo machete
- name: Fmt
run: cargo fmt --all -- --files-with-diff --check
build:
name: ${{ matrix.platform_name }}
runs-on: ${{ matrix.platform }}
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest'
platform_name: MacOS
build: 'pnpm tauri build --target universal-apple-darwin'
- platform: 'ubuntu-22.04'
platform_name: Linux (x64)
build: 'pnpm tauri build'
- platform: 'linux-arm64'
platform_name: Linux (ARM)
build: 'pnpm tauri build --target aarch64-unknown-linux-gnu'
- platform: 'windows-latest'
platform_name: Windows (x64)
build: 'pnpm tauri build'
- platform: 'windows-latest'
platform_name: Windows (ARM)
build: 'pnpm tauri build --target aarch64-pc-windows-msvc'
- platform: 'macos-latest'
platform_name: iOS
build: 'pnpm tauri ios build --export-method app-store-connect'
build_dev: 'pnpm tauri ios build --export-method debugging'
- platform: 'macos-latest'
platform_name: Android
build: 'pnpm tauri android build'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add x86_64-apple-darwin
if: matrix.platform_name == 'MacOS'
run: rustup target add x86_64-apple-darwin
- name: Add aarch64-apple-ios
if: matrix.platform_name == 'iOS'
run: rustup target add aarch64-apple-ios
- name: Add aarch64-pc-windows-msvc
if: matrix.platform_name == 'Windows (ARM)'
run: rustup target add aarch64-pc-windows-msvc
- name: Add aarch64-unknown-linux-gnu
if: matrix.platform_name == 'Linux (ARM)'
run: rustup target add aarch64-unknown-linux-gnu
- name: Add Android targets
if: matrix.platform_name == 'Android'
run: rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: Ubuntu dependencies
if: matrix.platform == 'ubuntu-22.04' || matrix.platform == 'linux-arm64'
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev
- name: Windows dependencies
if: matrix.platform == 'windows-latest'
run: |
choco install nasm
echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
if: matrix.platform_name == 'Android'
with:
ndk-version: r26d
link-to-sdk: true
add-to-path: true
- name: Add NDK toolchain to path
if: matrix.platform_name == 'Android'
run: echo "$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/bin" >> $GITHUB_PATH
env:
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
- name: Setup Android signing
if: matrix.platform_name == '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
- name: Install pnpm
uses: pnpm/action-setup@v4
- name: Frontend dependencies
run: pnpm install
- name: Save API key to file
if: matrix.platform == 'macos-latest'
run: |
mkdir -p ~/private_keys
echo -n '${{ secrets.APPLE_API_SECRET_KEY }}' > ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
- name: Bindgen CLI
run: cargo install bindgen-cli --locked
# On MacOS we only notarize on tagged releases
# On iOS we need these secrets as well to do code signing
- name: Build with secrets
if: ${{ (matrix.platform_name == 'MacOS' && startsWith(github.event.ref, 'refs/tags/v')) || matrix.platform_name == 'iOS' }}
run: ${{ startsWith(github.event.ref, 'refs/tags/v') && matrix.build || matrix.build_dev || matrix.build }}
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY_ID }}
APPLE_API_KEY_PATH: ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY_ID }}.p8
CI: true
# On Android we need to use the NDK environment variables.
- name: Build with NDK
if: matrix.platform_name == 'Android'
run: ${{ matrix.build }}
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
ANDROID_NDK: ${{ steps.setup-ndk.outputs.ndk-path }}
NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
CI: true
# We don't currently do signing on other platforms
- name: Build without secrets
if: ${{ !((matrix.platform_name == 'MacOS' && startsWith(github.event.ref, 'refs/tags/v')) || matrix.platform_name == 'iOS' || matrix.platform_name == 'Android') }}
run: ${{ matrix.build }}
env:
CI: true
# MacOS
- name: Upload APP (MacOS)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'MacOS'
with:
name: Sage.app
path: target/universal-apple-darwin/release/bundle/macos/*.app
- name: Upload DMG (MacOS)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'MacOS'
with:
name: Sage.dmg
path: target/universal-apple-darwin/release/bundle/dmg/*.dmg
- name: Release (MacOS)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'MacOS' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
target/universal-apple-darwin/release/bundle/macos/*.app
target/universal-apple-darwin/release/bundle/dmg/*.dmg
# Linux x64
- name: Upload DEB (Linux x64)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Linux (x64)'
with:
name: Sage_x64.deb
path: target/release/bundle/deb/*.deb
- name: Upload DMG (Linux x64)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Linux (x64)'
with:
name: Sage_x64.rpm
path: target/release/bundle/rpm/*.rpm
- name: Upload AppImage (Linux x64)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Linux (x64)'
with:
name: Sage_x64.AppImage
path: target/release/bundle/appimage/*.AppImage
- name: Release (Linux x64)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'Linux (x64)' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
target/release/bundle/deb/*.deb
target/release/bundle/rpm/*.rpm
target/release/bundle/appimage/*.AppImage
# Linux ARM
- name: Upload DEB (Linux ARM)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Linux (ARM)'
with:
name: Sage_ARM64.deb
path: target/aarch64-unknown-linux-gnu/release/bundle/deb/*.deb
- name: Upload DMG (Linux ARM)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Linux (ARM)'
with:
name: Sage_ARM64.rpm
path: target/aarch64-unknown-linux-gnu/release/bundle/rpm/*.rpm
- name: Upload AppImage (Linux ARM)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Linux (ARM)'
with:
name: Sage_ARM64.AppImage
path: target/aarch64-unknown-linux-gnu/release/bundle/appimage/*.AppImage
- name: Release (Linux ARM)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'Linux (ARM)' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
target/aarch64-unknown-linux-gnu/release/bundle/deb/*.deb
target/aarch64-unknown-linux-gnu/release/bundle/rpm/*.rpm
target/aarch64-unknown-linux-gnu/release/bundle/appimage/*.AppImage
# Windows x64
- name: Upload MSI (Windows x64)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Windows (x64)'
with:
name: Sage_x64.msi
path: target/release/bundle/msi/*.msi
- name: Upload EXE (Windows x64)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Windows (x64)'
with:
name: Sage_x64.exe
path: target/release/bundle/nsis/*.exe
- name: Release (Windows x64)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'Windows (x64)' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
target/release/bundle/msi/*.msi
target/release/bundle/nsis/*.exe
# Windows ARM
- name: Upload MSI (Windows ARM)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Windows (ARM)'
with:
name: Sage_ARM64.msi
path: target/aarch64-pc-windows-msvc/release/bundle/msi/*.msi
- name: Upload EXE (Windows ARM)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Windows (ARM)'
with:
name: Sage_ARM64.exe
path: target/aarch64-pc-windows-msvc/release/bundle/nsis/*.exe
- name: Release (Windows ARM)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'Windows (ARM)' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
target/aarch64-pc-windows-msvc/release/bundle/msi/*.msi
target/aarch64-pc-windows-msvc/release/bundle/nsis/*.exe
# iOS
- name: Upload IPA (iOS)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'iOS'
with:
name: Sage_iOS.ipa
path: src-tauri/gen/apple/build/arm64/*.ipa
- name: Release (iOS)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'iOS' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
src-tauri/gen/apple/build/arm64/*.ipa
- name: Upload to App Store (or TestFlight)
if: matrix.platform_name == 'iOS' && startsWith(github.event.ref, 'refs/tags/v')
run: xcrun altool --upload-app --type ios --file "src-tauri/gen/apple/build/arm64/Sage.ipa" --apiKey $APPLE_API_KEY_ID --apiIssuer $APPLE_API_ISSUER
env:
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
# Android
- name: Upload AAB (Android)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Android'
with:
name: Sage_Android.aab
path: src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab
- name: Upload APK (Android)
uses: actions/upload-artifact@v4
if: matrix.platform_name == 'Android'
with:
name: Sage_Android.apk
path: src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk
- name: Release (Android)
uses: softprops/action-gh-release@v2
if: matrix.platform_name == 'Android' && startsWith(github.event.ref, 'refs/tags/v')
with:
files: |
src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab
src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk