android-build #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.2.1 | |
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.5.0 | |
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 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 install | |
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: | | |
$ANDROID_HOME/build-tools/30.0.3/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/app-universal-release-unsigned-aligned.apk | |
- name: Decode keystore | |
run: | | |
echo ${{ secrets.KEYSTORE_BASE64 }} | base64 --decode > ./my-release-key.jks | |
- name: Sign apk | |
run: | | |
$ANDROID_HOME/build-tools/30.0.3/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/ztapp.apk \ | |
./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/app-universal-release-unsigned-aligned.apk | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
- name: Verify APK | |
run: | | |
$ANDROID_HOME/build-tools/30.0.3/apksigner verify ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztapp.apk | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: release | |
path: ./gui/src-tauri/gen/android/app/build/outputs/apk/universal/release/ztapp.apk |