Skip to content

Commit

Permalink
build: added bundle (.aab) building (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare authored Oct 8, 2023
1 parent e737d31 commit f38293c
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 93 deletions.
159 changes: 103 additions & 56 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:
pull_request:
branches: [ master ]

env:
NDK_VERSION: '25.2.9519653'
NODE_VERSION: '16'
JAVA_VERSION: '17'

jobs:
build-rust:
name: Build aw-server-rust (ndk-${{ matrix.ndk_version }}, node-${{ matrix.node_version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
ndk_version: ['25.2.9519653']
node_version: [16]
name: Build aw-server-rust
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -32,7 +32,8 @@ jobs:
cache-name: jniLibs
with:
path: mobile/src/main/jniLibs/
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ matrix.ndk_version }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}

- name: Display structure of downloaded files
if: steps.cache-jniLibs.outputs.cache-hit == 'true'
run: |
Expand All @@ -45,8 +46,8 @@ jobs:
- name: Install NDK
if: steps.cache-jniLibs.outputs.cache-hit != 'true'
run: |
sdkmanager "ndk;${{ matrix.ndk_version }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
sdkmanager "ndk;${{ env.NDK_VERSION }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
ls $ANDROID_NDK_HOME
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
Expand Down Expand Up @@ -81,35 +82,28 @@ jobs:
run: |
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
- name: Upload JNI libs
uses: actions/upload-artifact@v3
with:
name: jniLibs
path: mobile/src/main/jniLibs/

build-apk:
name: Build APK (${{ matrix.os }}, java-${{ matrix.java_version }})
runs-on: ${{ matrix.os }}
name: Build ${{ matrix.type }}
runs-on: ubuntu-20.04
needs: [build-rust]
env:
SUPPLY_TRACK: production # used by fastlane to determine track to publish to
strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-20.04]
java_version: [17]
ndk_version: ['25.2.9519653']
type: ['apk', 'aab']

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- uses: ActivityWatch/check-version-format-action@v2
id: version
with:
prefix: 'v'

- name: Echo version
run: |
echo "${{ steps.version.outputs.full }} (stable: ${{ steps.version.outputs.is_stable }})"
Expand All @@ -130,15 +124,15 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java_version }}
java-version: ${{ env.JAVA_VERSION }}

# Android SDK & NDK
- name: Set up Android SDK
uses: android-actions/setup-android@v2
- name: Install NDK
run: |
sdkmanager "ndk;${{ matrix.ndk_version }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
sdkmanager "ndk;${{ env.NDK_VERSION }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
ls $ANDROID_NDK_HOME
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
Expand All @@ -152,11 +146,17 @@ jobs:
- name: Install age
uses: adnsio/setup-age-action@v1.2.0

- name: Download JNI libs
uses: actions/download-artifact@v3
# Restores jniLibs from cache
# `actions/cache/restore` only restores, without saving back in a post-hook
- uses: actions/cache/restore@v3
id: cache-jniLibs
env:
cache-name: jniLibs
with:
name: jniLibs
path: mobile/src/main/jniLibs
path: mobile/src/main/jniLibs/
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
fail-on-cache-miss: true

- name: Check that jniLibs present
run: |
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
Expand All @@ -183,11 +183,6 @@ jobs:
- name: Update versionCode
run: bundle exec fastlane update_version

# Test
- name: Test
run: |
make test
- name: Load Android secrets
if: env.KEY_ANDROID_JKS != null
env:
Expand All @@ -197,35 +192,84 @@ jobs:
cat android.jks.age | age -d -i android.jks.key -o android.jks
rm android.jks.key
- name: Assemble APK
- name: Assemble
env:
JKS_STOREPASS: ${{ secrets.KEY_ANDROID_JKS_STOREPASS }}
JKS_KEYPASS: ${{ secrets.KEY_ANDROID_JKS_KEYPASS }}
run: |
make dist/aw-android.apk
make dist/aw-android.${{ matrix.type }}
- name: Upload release APK
- name: Upload
uses: actions/upload-artifact@v3
with:
name: aw-android
path: dist/aw-android*.apk
path: dist/aw-android*.${{ matrix.type }}

test:
name: Test
runs-on: ubuntu-20.04
needs: [build-rust]
env:
SUPPLY_TRACK: production # used by fastlane to determine track to publish to

steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'

- name: Set RELEASE
run: |
echo "RELEASE=${{ startsWith(github.ref_name, 'v') }}" >> $GITHUB_ENV
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}

# Android SDK & NDK
- name: Set up Android SDK
uses: android-actions/setup-android@v2
- name: Install NDK
run: |
sdkmanager "ndk;${{ env.NDK_VERSION }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
ls $ANDROID_NDK_HOME
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
# Restores jniLibs from cache
# `actions/cache/restore` only restores, without saving back in a post-hook
- uses: actions/cache/restore@v3
id: cache-jniLibs
env:
cache-name: jniLibs
with:
path: mobile/src/main/jniLibs/
key: ${{ env.cache-name }}-release-${{ env.RELEASE }}-ndk-${{ env.NDK_VERSION }}-${{ hashFiles('.git/modules/aw-server-rust/HEAD') }}
fail-on-cache-miss: true
- name: Check that jniLibs present
run: |
test -e mobile/src/main/jniLibs/x86_64/libaw_server.so
# Test
- name: Test
run: |
make test
test-e2e:
name: Test E2E ${{ matrix.android_avd }} #-${{ matrix.os }}-eAPI-${{ matrix.android_emu_version }}-java-${{ matrix.java_version }}-node-${{ matrix.node_version }}
name: Test E2E
needs: [build-rust]
if: false # disabled
runs-on: ${{ matrix.os }}
runs-on: "macos-12" # macOS-latest
env:
MATRIX_E_SDK: ${{ matrix.android_emu_version }}
MATRIX_AVD: ${{ matrix.android_avd }}
strategy:
fail-fast: false
max-parallel: 1
matrix:
os: [macos-12] # macOS-latest,
android_avd: [Pixel_API_27_AOSP]
java_version: [11]
ndk_version: ['25.2.9519653']
include:
- android_avd: Pixel_API_27_AOSP
android_emu_version: 27
Expand Down Expand Up @@ -284,7 +328,7 @@ jobs:
- name: Start Android emulator
timeout-minutes: 30 # ~4min normal - 3x DOSafety
env:
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}-${{ matrix.os }}
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
echo "Starting emulator and waiting for boot to complete...."
Expand Down Expand Up @@ -338,15 +382,15 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java_version }}
java-version: ${{ env.JAVA_VERSION }}

# Android SDK & NDK
- name: Set up Android SDK
uses: android-actions/setup-android@v2
- name: Install NDK
run: |
sdkmanager "ndk;${{ matrix.ndk_version }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ matrix.ndk_version }}"
sdkmanager "ndk;${{ env.NDK_VERSION }}"
ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
ls $ANDROID_NDK_HOME
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
Expand All @@ -366,7 +410,7 @@ jobs:
- name: Screenshot
if: ${{ success() || steps.test.conclusion == 'failure'}}
env:
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}-${{ matrix.os }}
SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}
run: |
adb shell monkey -p net.activitywatch.android.debug 1
sleep 10
Expand Down Expand Up @@ -412,13 +456,13 @@ jobs:
# cat GITHUB_STEP_SUMMARY.html >> $GITHUB_STEP_SUMMARY

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

- name: Download release APK
- name: Download APK & AAB
uses: actions/download-artifact@v3
with:
name: aw-android
Expand Down Expand Up @@ -464,16 +508,17 @@ jobs:
- name: Release with fastlane
run: |
bundle exec fastlane supply run --apk dist/*.apk
# bundle exec fastlane supply run --apk dist/*.apk
bundle exec fastlane supply run --aab dist/*.aab
release-gh:
needs: [build-apk]
needs: [build-apk, test]
if: startsWith(github.ref, 'refs/tags/v') # only on runs triggered from tag
runs-on: ubuntu-latest
steps:

# Will download all artifacts to path
- name: Download release APK
- name: Download release APK & AAB
uses: actions/download-artifact@v3
with:
name: aw-android
Expand All @@ -495,6 +540,8 @@ jobs:
with:
draft: true
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
files: dist/*.apk
files: |
dist/*.apk
dist/*.aab
# body_path: dist/release_notes/release_notes.md

10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,7 @@ captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/modules.xml
.idea/dictionaries
.idea/libraries
.idea/caches
.idea/deploymentTargetDropDown.xml
.idea

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
Expand Down
Loading

0 comments on commit f38293c

Please sign in to comment.