android-build #76
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@v4 | |
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 | |
- id: setup-rust | |
name: setup rust | |
uses: ningenMe/[email protected] | |
with: | |
rust-version: 1.81.0 | |
- name: Setup Rustup Target | |
run: | | |
rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android | |
- name: Build child plugin | |
run: | | |
cd gui/tauri-plugin-share | |
yarn install | |
yarn build | |
- 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: fix tao android bug | |
run: | | |
cd gui/src-tauri | |
cargo update -p tao | |
- 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/app-universal-release-unsigned-aligned.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-app-v${{ vars.APP_VERSION }}-android.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: | | |
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 |