-
Notifications
You must be signed in to change notification settings - Fork 111
91 lines (80 loc) · 3.17 KB
/
Copy pathandroid.yml
File metadata and controls
91 lines (80 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Android Build
on:
workflow_dispatch:
pull_request:
paths:
# Android project itself, plus the shared C++ runtime it compiles from source.
- "runtime/android/**"
- "runtime/bindings/android/**"
- "runtime/CMakeLists.txt"
- "runtime/CMakePresets.json"
- "runtime/processor/**"
- "runtime/utils/**"
- "runtime/cmake/**"
- ".github/workflows/android.yml"
jobs:
build-android:
name: build (android)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
# Caches downloaded Gradle distribution and dependencies across runs.
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
build-root-directory: runtime/android
# Puts sdkmanager on PATH, accepts licenses, installs platform + build-tools.
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
packages: 'platforms;android-36 build-tools;36.0.0'
# sdkmanager has no bare "ndk" package — must install "ndk;X.Y.Z". Pick the
# newest side-by-side NDK from the package list.
- name: Install NDK (latest)
run: |
NDK_PKG=$(sdkmanager --list 2>/dev/null \
| grep -oE 'ndk;[0-9]+\.[0-9]+\.[0-9]+' \
| sort -t';' -k2 -V \
| tail -1)
if [ -z "$NDK_PKG" ]; then
echo "ERROR: no ndk;* package found in sdkmanager --list" >&2
sdkmanager --list 2>/dev/null | grep -i ndk | head -20 >&2 || true
exit 1
fi
echo "Installing $NDK_PKG"
sdkmanager --install "$NDK_PKG"
NDK_VER="${NDK_PKG#ndk;}"
echo "Using NDK $NDK_VER"
echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/$NDK_VER" >> "$GITHUB_ENV"
# Build the native lib with CMake presets and install it into jniLibs/<abi>/.
# Gradle does NOT drive CMake; it only packages the prebuilt .so.
- name: Build native lib
working-directory: runtime
run: |
cmake --preset android-arm64-v8a
cmake --build --preset android-arm64-v8a
cmake --install build/aarch64-linux-android --component jni
- uses: actions/setup-python@v5
with:
python-version: '3.x'
# Generate the four FST models straight into assets/ so the APK ships with
# them (the app loads zh_tn_* and zh_itn_* at runtime).
- name: Generate model assets
run: |
pip install pynini importlib_resources
assets=runtime/android/app/src/main/assets
python -m tn --language zh --overwrite_cache --cache_dir "$assets"
python -m itn --language zh --overwrite_cache --cache_dir "$assets"
- name: Build release APK
working-directory: runtime/android
run: ./gradlew :app:assembleRelease -PabiFilters=arm64-v8a --no-daemon
- name: Upload release APK
uses: actions/upload-artifact@v4
with:
name: app-release-arm64-v8a
path: runtime/android/app/build/outputs/apk/release/app-release.apk
if-no-files-found: error