Skip to content

Commit f38293c

Browse files
authored
build: added bundle (.aab) building (#100)
1 parent e737d31 commit f38293c

5 files changed

Lines changed: 160 additions & 93 deletions

File tree

.github/workflows/build.yml

Lines changed: 103 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ on:
88
pull_request:
99
branches: [ master ]
1010

11+
env:
12+
NDK_VERSION: '25.2.9519653'
13+
NODE_VERSION: '16'
14+
JAVA_VERSION: '17'
15+
1116
jobs:
1217
build-rust:
13-
name: Build aw-server-rust (ndk-${{ matrix.ndk_version }}, node-${{ matrix.node_version }})
14-
runs-on: ${{ matrix.os }}
15-
strategy:
16-
matrix:
17-
os: [ubuntu-20.04]
18-
ndk_version: ['25.2.9519653']
19-
node_version: [16]
18+
name: Build aw-server-rust
19+
runs-on: ubuntu-20.04
2020
steps:
2121
- uses: actions/checkout@v3
2222
with:
@@ -32,7 +32,8 @@ jobs:
3232
cache-name: jniLibs
3333
with:
3434
path: mobile/src/main/jniLibs/
35-
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ matrix.ndk_version }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
35+
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
36+
3637
- name: Display structure of downloaded files
3738
if: steps.cache-jniLibs.outputs.cache-hit == 'true'
3839
run: |
@@ -45,8 +46,8 @@ jobs:
4546
- name: Install NDK
4647
if: steps.cache-jniLibs.outputs.cache-hit != 'true'
4748
run: |
48-
sdkmanager "ndk;${{ matrix.ndk_version }}"
49-
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
49+
sdkmanager "ndk;${{ env.NDK_VERSION }}"
50+
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
5051
ls $ANDROID_NDK_HOME
5152
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
5253
@@ -81,35 +82,28 @@ jobs:
8182
run: |
8283
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
8384
84-
- name: Upload JNI libs
85-
uses: actions/upload-artifact@v3
86-
with:
87-
name: jniLibs
88-
path: mobile/src/main/jniLibs/
89-
9085
9186
build-apk:
92-
name: Build APK (${{ matrix.os }}, java-${{ matrix.java_version }})
93-
runs-on: ${{ matrix.os }}
87+
name: Build ${{ matrix.type }}
88+
runs-on: ubuntu-20.04
9489
needs: [build-rust]
9590
env:
9691
SUPPLY_TRACK: production # used by fastlane to determine track to publish to
9792
strategy:
98-
fail-fast: false
93+
fail-fast: true
9994
matrix:
100-
os: [ubuntu-20.04]
101-
java_version: [17]
102-
ndk_version: ['25.2.9519653']
95+
type: ['apk', 'aab']
96+
10397
steps:
10498
- uses: actions/checkout@v2
10599
with:
106100
submodules: 'recursive'
107-
101+
108102
- uses: ActivityWatch/check-version-format-action@v2
109103
id: version
110104
with:
111105
prefix: 'v'
112-
106+
113107
- name: Echo version
114108
run: |
115109
echo "${{ steps.version.outputs.full }} (stable: ${{ steps.version.outputs.is_stable }})"
@@ -130,15 +124,15 @@ jobs:
130124
- name: Set up JDK
131125
uses: actions/setup-java@v1
132126
with:
133-
java-version: ${{ matrix.java_version }}
127+
java-version: ${{ env.JAVA_VERSION }}
134128

135129
# Android SDK & NDK
136130
- name: Set up Android SDK
137131
uses: android-actions/setup-android@v2
138132
- name: Install NDK
139133
run: |
140-
sdkmanager "ndk;${{ matrix.ndk_version }}"
141-
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
134+
sdkmanager "ndk;${{ env.NDK_VERSION }}"
135+
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
142136
ls $ANDROID_NDK_HOME
143137
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
144138
@@ -152,11 +146,17 @@ jobs:
152146
- name: Install age
153147
uses: adnsio/setup-age-action@v1.2.0
154148

155-
- name: Download JNI libs
156-
uses: actions/download-artifact@v3
149+
# Restores jniLibs from cache
150+
# `actions/cache/restore` only restores, without saving back in a post-hook
151+
- uses: actions/cache/restore@v3
152+
id: cache-jniLibs
153+
env:
154+
cache-name: jniLibs
157155
with:
158-
name: jniLibs
159-
path: mobile/src/main/jniLibs
156+
path: mobile/src/main/jniLibs/
157+
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
158+
fail-on-cache-miss: true
159+
160160
- name: Check that jniLibs present
161161
run: |
162162
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
@@ -183,11 +183,6 @@ jobs:
183183
- name: Update versionCode
184184
run: bundle exec fastlane update_version
185185

186-
# Test
187-
- name: Test
188-
run: |
189-
make test
190-
191186
- name: Load Android secrets
192187
if: env.KEY_ANDROID_JKS != null
193188
env:
@@ -197,35 +192,84 @@ jobs:
197192
cat android.jks.age | age -d -i android.jks.key -o android.jks
198193
rm android.jks.key
199194
200-
- name: Assemble APK
195+
- name: Assemble
201196
env:
202197
JKS_STOREPASS: ${{ secrets.KEY_ANDROID_JKS_STOREPASS }}
203198
JKS_KEYPASS: ${{ secrets.KEY_ANDROID_JKS_KEYPASS }}
204199
run: |
205-
make dist/aw-android.apk
200+
make dist/aw-android.${{ matrix.type }}
206201
207-
- name: Upload release APK
202+
- name: Upload
208203
uses: actions/upload-artifact@v3
209204
with:
210205
name: aw-android
211-
path: dist/aw-android*.apk
206+
path: dist/aw-android*.${{ matrix.type }}
207+
208+
test:
209+
name: Test
210+
runs-on: ubuntu-20.04
211+
needs: [build-rust]
212+
env:
213+
SUPPLY_TRACK: production # used by fastlane to determine track to publish to
214+
215+
steps:
216+
- uses: actions/checkout@v2
217+
with:
218+
submodules: 'recursive'
219+
220+
- name: Set RELEASE
221+
run: |
222+
echo "RELEASE=${{ startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV
223+
224+
- name: Set up JDK
225+
uses: actions/setup-java@v1
226+
with:
227+
java-version: ${{ env.JAVA_VERSION }}
228+
229+
# Android SDK & NDK
230+
- name: Set up Android SDK
231+
uses: android-actions/setup-android@v2
232+
- name: Install NDK
233+
run: |
234+
sdkmanager "ndk;${{ env.NDK_VERSION }}"
235+
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
236+
ls $ANDROID_NDK_HOME
237+
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
238+
239+
240+
# Restores jniLibs from cache
241+
# `actions/cache/restore` only restores, without saving back in a post-hook
242+
- uses: actions/cache/restore@v3
243+
id: cache-jniLibs
244+
env:
245+
cache-name: jniLibs
246+
with:
247+
path: mobile/src/main/jniLibs/
248+
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
249+
fail-on-cache-miss: true
250+
- name: Check that jniLibs present
251+
run: |
252+
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
253+
254+
# Test
255+
- name: Test
256+
run: |
257+
make test
258+
212259
213260
test-e2e:
214-
name: Test E2E ${{ matrix.android_avd }} #-${{ matrix.os }}-eAPI-${{ matrix.android_emu_version }}-java-${{ matrix.java_version }}-node-${{ matrix.node_version }}
261+
name: Test E2E
215262
needs: [build-rust]
216263
if: false # disabled
217-
runs-on: ${{ matrix.os }}
264+
runs-on: "macos-12" # macOS-latest
218265
env:
219266
MATRIX_E_SDK: ${{ matrix.android_emu_version }}
220267
MATRIX_AVD: ${{ matrix.android_avd }}
221268
strategy:
222269
fail-fast: false
223270
max-parallel: 1
224271
matrix:
225-
os: [macos-12] # macOS-latest,
226272
android_avd: [Pixel_API_27_AOSP]
227-
java_version: [11]
228-
ndk_version: ['25.2.9519653']
229273
include:
230274
- android_avd: Pixel_API_27_AOSP
231275
android_emu_version: 27
@@ -284,7 +328,7 @@ jobs:
284328
- name: Start Android emulator
285329
timeout-minutes: 30 # ~4min normal - 3x DOSafety
286330
env:
287-
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}-${{ matrix.os }}
331+
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}
288332
HOMEBREW_NO_INSTALL_CLEANUP: 1
289333
run: |
290334
echo "Starting emulator and waiting for boot to complete...."
@@ -338,15 +382,15 @@ jobs:
338382
- name: Set up JDK
339383
uses: actions/setup-java@v1
340384
with:
341-
java-version: ${{ matrix.java_version }}
385+
java-version: ${{ env.JAVA_VERSION }}
342386

343387
# Android SDK & NDK
344388
- name: Set up Android SDK
345389
uses: android-actions/setup-android@v2
346390
- name: Install NDK
347391
run: |
348-
sdkmanager "ndk;${{ matrix.ndk_version }}"
349-
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
392+
sdkmanager "ndk;${{ env.NDK_VERSION }}"
393+
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
350394
ls $ANDROID_NDK_HOME
351395
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
352396
@@ -366,7 +410,7 @@ jobs:
366410
- name: Screenshot
367411
if: ${{ success() || steps.test.conclusion == 'failure'}}
368412
env:
369-
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}-${{ matrix.os }}
413+
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}
370414
run: |
371415
adb shell monkey -p net.activitywatch.android.debug 1
372416
sleep 10
@@ -412,13 +456,13 @@ jobs:
412456
# cat GITHUB_STEP_SUMMARY.html >> $GITHUB_STEP_SUMMARY
413457

414458
release-fastlane:
415-
needs: [build-apk]
459+
needs: [build-apk, test]
416460
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
417461
runs-on: ubuntu-latest
418462
steps:
419463
- uses: actions/checkout@v3
420464

421-
- name: Download release APK
465+
- name: Download APK & AAB
422466
uses: actions/download-artifact@v3
423467
with:
424468
name: aw-android
@@ -464,16 +508,17 @@ jobs:
464508
465509
- name: Release with fastlane
466510
run: |
467-
bundle exec fastlane supply run --apk dist/*.apk
511+
# bundle exec fastlane supply run --apk dist/*.apk
512+
bundle exec fastlane supply run --aab dist/*.aab
468513
469514
release-gh:
470-
needs: [build-apk]
515+
needs: [build-apk, test]
471516
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
472517
runs-on: ubuntu-latest
473518
steps:
474519

475520
# Will download all artifacts to path
476-
- name: Download release APK
521+
- name: Download release APK & AAB
477522
uses: actions/download-artifact@v3
478523
with:
479524
name: aw-android
@@ -495,6 +540,8 @@ jobs:
495540
with:
496541
draft: true
497542
prerelease: ${{ !(steps.version.outputs.is_stable == 'true') }} # must compare to true, since boolean outputs are actually just strings, and "false" is truthy since it's not empty: https://github.com/actions/runner/issues/1483#issuecomment-994986996
498-
files: dist/*.apk
543+
files: |
544+
dist/*.apk
545+
dist/*.aab
499546
# body_path: dist/release_notes/release_notes.md
500547

.gitignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ captures/
5151

5252
# IntelliJ
5353
*.iml
54-
.idea/workspace.xml
55-
.idea/tasks.xml
56-
.idea/gradle.xml
57-
.idea/assetWizardSettings.xml
58-
.idea/modules.xml
59-
.idea/dictionaries
60-
.idea/libraries
61-
.idea/caches
62-
.idea/deploymentTargetDropDown.xml
54+
.idea
6355

6456
# Keystore files
6557
# Uncomment the following lines if you do not want to check your keystore files in.

0 commit comments

Comments
 (0)