Repository navigation
238 lines (212 loc) · 8.03 KB
/
Copy pathandroid-build.yml
File metadata and controls
238 lines (212 loc) · 8.03 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
name: Android Build
on:
workflow_dispatch:
inputs:
gradle_task:
description: Gradle task to run
required: true
default: assembleDebug
type: choice
options:
- assembleDebug
- ':app:assembleNightly'
- ':app:assembleClone'
- ':app:bundleRelease'
push:
branches: [main]
paths:
- .github/workflows/android-build.yml
- .gitmodules
- .npmrc
- app/**
- build.gradle.kts
- ci/script/download_android_dependencies.sh
- ci/script/prepare_android_dependencies.py
- cmake/**
- avator/**
- examples/**
- gradle/**
- gradle.properties
- gradlew
- gradlew.bat
- llm/**
- package.json
- package-lock.json
- npm-shrinkwrap.json
- pnpm-workspace.yaml
- quickjs/**
- settings.gradle.kts
- showerclient/**
- terminal/**
- terminal
- tools/native_ripgrep/**
- tools/packages_whitelist.txt
- tools/example_packages/sync_example_packages.py
- web-chat/**
concurrency:
group: android-build-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
JAVA_VERSION: '21'
NODE_VERSION: '22'
ANDROID_NDK_VERSION: '25.1.8937393'
ANDROID_CMAKE_VERSION: '3.22.1'
ANDROID_API_LEVEL: '26'
RUST_VERSION: '1.88.0'
MANUAL_DEPS_DIR: manual-deps
jobs:
build:
name: Build Android artifacts
runs-on: ubuntu-24.04
timeout-minutes: 240
steps:
- name: Checkout source
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
ref: ${{ github.sha }}
fetch-depth: 1
persist-credentials: false
submodules: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Initialize terminal submodule
shell: bash
run: |
set -euo pipefail
git submodule sync -- terminal
git submodule update --init --recursive --depth 1 terminal
git submodule status -- terminal
- name: Set up JDK
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
cache: gradle
- name: Set up Node.js
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up Android SDK
uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4
with:
packages: ''
- name: Install Android SDK, NDK and CMake
shell: bash
run: |
set -euo pipefail
sdkmanager --install \
"platform-tools" \
"platforms;android-34" \
"platforms;android-36" \
"build-tools;34.0.0" \
"build-tools;35.0.0" \
"ndk;$ANDROID_NDK_VERSION" \
"cmake;$ANDROID_CMAKE_VERSION"
- name: Restore Android CMake source cache
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: |
**/.cxx/operit_deps/*-src
key: android-cmake-sources-${{ runner.os }}-${{ runner.arch }}-arm64-v8a-ndk-${{ env.ANDROID_NDK_VERSION }}-cmake-${{ env.ANDROID_CMAKE_VERSION }}-${{ hashFiles('cmake/**', '**/CMakeLists.txt', '**/*.cmake', '**/build.gradle.kts', 'gradle.properties') }}
- name: Restore Android dependency cache
id: cache-manual-deps
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: ${{ env.MANUAL_DEPS_DIR }}
key: android-full-deps-${{ runner.os }}-${{ hashFiles('ci/script/download_android_dependencies.sh', 'ci/script/prepare_android_dependencies.py') }}
- name: Restore generated STT asset cache
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: app/build/generated/stt-model-assets
key: stt-model-assets-${{ runner.os }}-${{ hashFiles('app/config/stt-model-assets.properties') }}
- name: Download Android dependencies
if: steps.cache-manual-deps.outputs.cache-hit != 'true'
run: bash ci/script/download_android_dependencies.sh full "$MANUAL_DEPS_DIR"
- name: Prepare Android dependencies
run: |
python3 ci/script/prepare_android_dependencies.py \
--profile full \
--archives "$MANUAL_DEPS_DIR" \
--repository "$GITHUB_WORKSPACE"
- name: Restore native ripgrep cache
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
with:
path: |
~/.cargo/registry
~/.cargo/git
tools/native_ripgrep/target
key: native-ripgrep-arm64-${{ runner.os }}-${{ runner.arch }}-ndk-${{ env.ANDROID_NDK_VERSION }}-api-${{ env.ANDROID_API_LEVEL }}-rust-${{ env.RUST_VERSION }}-${{ hashFiles('tools/native_ripgrep/Cargo.toml', 'tools/native_ripgrep/Cargo.lock', 'tools/native_ripgrep/**/*.rs', 'tools/native_ripgrep/build_native_ripgrep.ps1') }}
- name: Build native ripgrep
shell: bash
run: |
set -euo pipefail
export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/$ANDROID_NDK_VERSION"
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android${ANDROID_API_LEVEL}-clang"
rustup toolchain install "$RUST_VERSION" --profile minimal
rustup target add --toolchain "$RUST_VERSION" aarch64-linux-android
cargo "+$RUST_VERSION" build \
--manifest-path tools/native_ripgrep/Cargo.toml \
--release \
--target aarch64-linux-android \
--locked
install -Dm755 \
tools/native_ripgrep/target/aarch64-linux-android/release/liboperit_ripgrep.so \
app/src/main/jniLibs/arm64-v8a/liboperit_ripgrep.so
test -s app/src/main/jniLibs/arm64-v8a/liboperit_ripgrep.so
- name: Install JavaScript dependencies
shell: bash
run: |
set -euo pipefail
npm install -g pnpm@10.34.5
npm ci --no-audit --no-fund
npm --prefix web-chat ci --no-audit --no-fund
- name: Build WebChat assets
run: |
npm run build:webchat
- name: Build bundled ToolPkg packages
run: |
npm run build:examples:github
python3 tools/example_packages/sync_example_packages.py --no-hot-reload
- name: Configure Android SDK
shell: bash
run: |
set -euo pipefail
echo "sdk.dir=$ANDROID_HOME" > local.properties
- name: Run Gradle build
env:
DISPATCH_GRADLE_TASK: ${{ inputs.gradle_task }}
EVENT_NAME: ${{ github.event_name }}
shell: bash
run: |
set -euo pipefail
case "$EVENT_NAME" in
push) gradle_task=assembleDebug ;;
workflow_dispatch) gradle_task="$DISPATCH_GRADLE_TASK" ;;
*) echo "Unsupported workflow event: $EVENT_NAME" >&2; exit 2 ;;
esac
chmod +x ./gradlew
./gradlew "$gradle_task" --stacktrace --no-daemon
- name: Upload Android reports
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: operit-android-reports-${{ github.run_number }}
path: |
app/build/reports/**
build/reports/**
if-no-files-found: warn
retention-days: 14
- name: Upload successful Android outputs
if: success()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: operit-android-${{ github.run_number }}
path: |
app/build/outputs/apk/**/*.apk
app/build/outputs/bundle/**/*.aab
if-no-files-found: error
retention-days: 14