Skip to content

android-build

android-build #65

Workflow file for this run

name: android-build
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '21'
- name: Setup Java JDK
uses: actions/setup-java@v4
with:
java-version: '17.0.10'
distribution: adopt
- name: Setup Android SDK
uses: Swisyn/setup-android-sdk@v1
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
with:
# Exact version to use
ndk-version: r26d
# Add installed NDK to the Android SDK
link-to-sdk: true
- uses: seanmiddleditch/gha-setup-ninja@v4
id: setup-ninja
with:
version: 1.11.1
- name: Setup Rustup Target
run: |
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android
- name: Build child app
run: |
cd gui
yarn install
yarn build:apps
- name: Build ztm
run: |
cd gui
ls /opt/hostedtoolcache/Java_Adopt_jdk/17.0.10-7
export JAVA_HOME='/opt/hostedtoolcache/Java_Adopt_jdk/17.0.10-7/x64'
ls /usr/local/lib/android/sdk
export ANDROID_HOME='/usr/local/lib/android/sdk'
ls -d $ANDROID_HOME/ndk/* | sort -V | tail -n 1 | xargs basename
export NDK="$ANDROID_HOME/ndk/$(ls -d $ANDROID_HOME/ndk/* | sort -V | tail -n 1 | xargs basename)"
yarn build-ztm-android
- name: Build apk
run: |
cd gui
export JAVA_HOME='/opt/hostedtoolcache/Java_Adopt_jdk/17.0.10-7/x64'
export ANDROID_HOME='/usr/local/lib/android/sdk'
export NDK_HOME="$ANDROID_HOME/ndk/$(ls -d $ANDROID_HOME/ndk/* | sort -V | tail -n 1 | xargs basename)"
yarn android-init
cp -f ./src-android/app/src/main/assets/libc++_shared.so ./src-tauri/bin/cli-aarch64-apple-darwin
NODE_OPTIONS="--max-old-space-size=4096" yarn android-build
- name: Align apk
run: |
export JAVA_HOME='/opt/hostedtoolcache/Java_Adopt_jdk/17.0.10-7/x64'
export ANDROID_HOME='/usr/local/lib/android/sdk'
ls $ANDROID_HOME
ls $ANDROID_HOME/build-tools
$ANDROID_HOME/build-tools/31.0.0/zipalign -v 4 ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned.apk ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztm-app-v${{ vars.APP_VERSION }}-android.apk
- name: Decode keystore
run: |
echo ${{ secrets.KEYSTORE_BASE64 }} | base64 --decode > ./my-release-key.jks
- name: Sign apk
run: |
export JAVA_HOME='/opt/hostedtoolcache/Java_Adopt_jdk/17.0.10-7/x64'
export ANDROID_HOME='/usr/local/lib/android/sdk'
$ANDROID_HOME/build-tools/31.0.0/apksigner sign --ks ./my-release-key.jks \
--ks-pass env:KEYSTORE_PASSWORD \
--key-pass env:KEY_PASSWORD \
--ks-key-alias "${{ secrets.KEY_ALIAS }}" \
--out ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztm.apk \
./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztm-app-v${{ vars.APP_VERSION }}-android.apk
env:
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Verify APK
run: |
export JAVA_HOME='/opt/hostedtoolcache/Java_Adopt_jdk/17.0.10-7/x64'
export ANDROID_HOME='/usr/local/lib/android/sdk'
$ANDROID_HOME/build-tools/31.0.0/apksigner verify ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztm-app-v${{ vars.APP_VERSION }}-android.apk
- uses: actions/upload-artifact@v3
with:
name: ztm-app-v${{ vars.APP_VERSION }}-android
path: ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztm-app-v${{ vars.APP_VERSION }}-android.apk
- uses: actions/upload-artifact@v3
with:
name: ztm-lib-v${{ vars.APP_VERSION }}-android
path: |
./gui/src-android/app/src/main/assets/libc++_shared.so
./gui/src-android/app/src/main/assets/libztm.so