-
Notifications
You must be signed in to change notification settings - Fork 12
284 lines (246 loc) · 8.87 KB
/
build_android.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
name: "Android Build"
on:
workflow_call:
secrets:
ANDROID_KEY_ALIAS:
required: true
ANDROID_KEY_PASSWORD:
required: true
ANDROID_KEY_BASE64:
required: true
push:
branches:
- master
paths:
- 'src-tauri/**'
- 'src/**'
- 'static/**'
- 'package.json'
- 'bun.lockb'
- 'svelte.config.js'
- 'tailwind.config.js'
- 'vite.config.js'
- '.github/workflows/build_android.yml'
pull_request:
paths:
- 'src-tauri/**'
- 'src/**'
- 'static/**'
- 'package.json'
- 'bun.lockb'
- 'svelte.config.js'
- 'tailwind.config.js'
- 'vite.config.js'
- '.github/workflows/build_android.yml'
jobs:
setup:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Get version
id: get-version
run: |
VERSION=$(grep '^version[[:space:]]*=[[:space:]]*"' src-tauri/Cargo.toml | sed 's/^version[[:space:]]*=[[:space:]]*"\(.*\)"/\1/')
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
build-android-universal:
needs: setup
runs-on: ubuntu-22.04
env:
NDK_VERSION: "25.2.9519653"
ANDROID_NDK_HOME: ${{ github.workspace }}/android-ndk-25.2.9519653
NDK_HOME: ${{ github.workspace }}/android-ndk-25.2.9519653
JAVA_HOME: /usr/lib/jvm/temurin-17-jdk-amd64
VERSION: ${{ needs.setup.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: false
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.39
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "src-tauri -> target"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Cache Android NDK
id: cache-ndk
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_NDK_HOME }}
key: android-ndk-${{ env.NDK_VERSION }}
- name: Install Android NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
sdkmanager --install "ndk;${{ env.NDK_VERSION }}"
mkdir -p ${{ env.ANDROID_NDK_HOME }}
cp -r $ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}/* ${{ env.ANDROID_NDK_HOME }}/
- 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: Install frontend dependencies
run: bun install
- name: Clean npm cache
run: bun clean || true
- name: Setup Android signing
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: Build Android universal binary
run: bun tauri android build
- name: Prepare universal artifact
run: |
mkdir -p android-artifacts
# Copy and rename universal AAB
cp src-tauri/gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab android-artifacts/whitenoise-${VERSION}-android-universal.aab
cp src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release.apk android-artifacts/whitenoise-${VERSION}-android-universal.apk
# Generate checksums
cd android-artifacts
for file in *; do
sha256sum "$file" > "${file}.sha256"
done
- name: Upload universal artifact
uses: actions/upload-artifact@v4
with:
name: android-universal
path: android-artifacts/*
if-no-files-found: error
build-android-split:
needs: setup
runs-on: ubuntu-22.04
env:
NDK_VERSION: "25.2.9519653"
ANDROID_NDK_HOME: ${{ github.workspace }}/android-ndk-25.2.9519653
NDK_HOME: ${{ github.workspace }}/android-ndk-25.2.9519653
JAVA_HOME: /usr/lib/jvm/temurin-17-jdk-amd64
VERSION: ${{ needs.setup.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
android: false
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.39
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "src-tauri -> target"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Cache Android NDK
id: cache-ndk
uses: actions/cache@v4
with:
path: ${{ env.ANDROID_NDK_HOME }}
key: android-ndk-${{ env.NDK_VERSION }}
- name: Install Android NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
sdkmanager --install "ndk;${{ env.NDK_VERSION }}"
mkdir -p ${{ env.ANDROID_NDK_HOME }}
cp -r $ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}/* ${{ env.ANDROID_NDK_HOME }}/
- 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: Install frontend dependencies
run: bun install
- name: Clean npm cache
run: bun clean || true
- name: Setup Android signing
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: Build Android split APKs
run: bun tauri android build --apk --split-per-abi
- name: Prepare split artifacts
run: |
mkdir -p android-artifacts
# Copy and rename split APKs with exact paths
cp src-tauri/gen/android/app/build/outputs/apk/arm64/release/app-arm64-release.apk android-artifacts/whitenoise-${VERSION}-android-arm64.apk
cp src-tauri/gen/android/app/build/outputs/apk/arm/release/app-arm-release.apk android-artifacts/whitenoise-${VERSION}-android-arm.apk
cp src-tauri/gen/android/app/build/outputs/apk/x86_64/release/app-x86_64-release.apk android-artifacts/whitenoise-${VERSION}-android-x86_64.apk
cp src-tauri/gen/android/app/build/outputs/apk/x86/release/app-x86-release.apk android-artifacts/whitenoise-${VERSION}-android-x86.apk
# Generate checksums
cd android-artifacts
for file in *.apk; do
sha256sum "$file" > "${file}.sha256"
done
- name: Upload split artifacts
uses: actions/upload-artifact@v4
with:
name: android-split
path: android-artifacts/*
if-no-files-found: error
collect-android-artifacts:
needs: [setup, build-android-universal, build-android-split]
runs-on: ubuntu-22.04
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: android-*
path: all-artifacts
merge-multiple: true
- name: Upload combined artifacts
uses: actions/upload-artifact@v4
with:
name: android
path: all-artifacts/*
if-no-files-found: error