-
Notifications
You must be signed in to change notification settings - Fork 10
270 lines (234 loc) · 9.83 KB
/
Copy pathandroid.yml
File metadata and controls
270 lines (234 loc) · 9.83 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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
name: android
on:
push:
# release branches are `release.yml`'s alone
branches-ignore:
- 'releases'
- 'release/**'
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: version to publish (e.g. 6.0.0-test1)
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# See the cache-key comment in `build_test.yml` for why the keys look like this.
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 1G
CCACHE_KEY_SUFFIX: r1
CONAN_HOME: ${{ github.workspace }}/.conan2
CONAN_KEY_SUFFIX: r1
NDK_VERSION: 28.1.13356709
jobs:
# One cross build per ABI, uploaded as an artifact so the AAR job below can
# assemble all of them without cross compiling four times in one runner.
native:
runs-on: ubuntu-24.04
env:
CACHE_FLAVOR: aar
strategy:
fail-fast: false
matrix:
architecture: [armv7, armv8, x86, x86_64]
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: install ccache
run: |
sudo apt install ccache
ccache -V
- name: setup python 3.14
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: 3.14
- name: install python dependencies
run: pip install conan
- name: install NDK
run: yes | ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "ndk;${NDK_VERSION}"
- name: conan cache key
shell: bash
run: echo "CONAN_CACHE_KEY=${{ hashFiles('conanfile.py', '.github/config/conan/**') }}" >> "$GITHUB_ENV"
- name: cache conan
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.CONAN_HOME }}
key: conan-${{ env.CACHE_FLAVOR }}-android-${{ matrix.architecture }}-${{ env.CONAN_KEY_SUFFIX }}-${{ env.CONAN_CACHE_KEY }}
restore-keys: |
conan-${{ env.CACHE_FLAVOR }}-android-${{ matrix.architecture }}-${{ env.CONAN_KEY_SUFFIX }}-
- name: conan config
run: conan config install .github/config/conan
- name: restore ccache
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.CACHE_FLAVOR }}-android-${{ matrix.architecture }}-${{ env.CCACHE_KEY_SUFFIX }}-${{ github.run_id }}
restore-keys: |
ccache-${{ env.CACHE_FLAVOR }}-android-${{ matrix.architecture }}-${{ env.CCACHE_KEY_SUFFIX }}-
# Cross compiling the bindings is the cheap half of the guard: #628 was a
# compile error in jni/src that only android sees, and no host job can.
- name: build
run: >
python android/build_native.py
--abi ${{ matrix.architecture }}
--build-profile ubuntu-24.04-clang-18
- name: save ccache
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ env.CACHE_FLAVOR }}-android-${{ matrix.architecture }}-${{ env.CCACHE_KEY_SUFFIX }}-${{ github.run_id }}
- name: upload native libraries
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: android-native-${{ matrix.architecture }}
path: android/native/prebuilt
if-no-files-found: error
aar:
needs: native
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: setup java
uses: actions/setup-java@f4f1212c880fdec8162ea9a6493f4495191887b4 # v5
with:
distribution: temurin
java-version: 21
- name: setup gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
# each ABI's artifact carries its own jniLibs/<abi>, so they merge into
# the one prebuilt tree the gradle build reads
- name: download native libraries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: android-native-*
merge-multiple: true
path: android/native/prebuilt
# -Podr.abis= : the libraries are the artifacts downloaded above, so the
# build must not try to cross compile them again
- name: lint
working-directory: android
run: ./gradlew lint -Podr.abis=
- name: assemble
working-directory: android
run: ./gradlew assembleRelease -Podr.abis=
- name: upload aar
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: odr-core-android
path: android/build/outputs/aar/*.aar
if-no-files-found: error
# The other half of the guard, and the only one that sees what a device sees:
# API 26 is the floor OpenDocument.droid ships to, where a java.* method the
# JDK has and android does not throws at the call (#621).
instrumented:
needs: native
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
api-level: [26, 36]
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: setup java
uses: actions/setup-java@f4f1212c880fdec8162ea9a6493f4495191887b4 # v5
with:
distribution: temurin
java-version: 21
- name: setup gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
# the emulator is x86_64, and nothing here needs the other ABIs
- name: download native libraries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: android-native-x86_64
path: android/native/prebuilt
- name: enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: instrumented tests
uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
with:
api-level: ${{ matrix.api-level }}
arch: x86_64
target: ${{ matrix.api-level >= 30 && 'google_apis' || 'default' }}
working-directory: android
script: ./gradlew connectedDebugAndroidTest -Podr.abis=
- name: upload test report
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: instrumented-report-${{ matrix.api-level }}
path: android/build/reports/androidTests
# Nothing reaches GitHub Packages that the device suite has not run: an AAR
# that assembles and lints is not evidence the bindings work on a device,
# which is the whole point of the two jobs above.
publish:
if: github.event_name != 'push'
needs: [aar, instrumented]
runs-on: ubuntu-24.04
# holds the portal token and the signing key
environment: maven-central
permissions:
contents: read
packages: write
steps:
- name: checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: setup java
uses: actions/setup-java@f4f1212c880fdec8162ea9a6493f4495191887b4 # v5
with:
distribution: temurin
java-version: 21
- name: setup gradle
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6
- name: download native libraries
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
pattern: android-native-*
merge-multiple: true
path: android/native/prebuilt
- name: get version
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
if [ "${{ github.event_name }}" = release ]; then
echo "ODR_VERSION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV
else
echo "ODR_VERSION=${INPUT_VERSION}" >> $GITHUB_ENV
fi
- name: publish to github packages
working-directory: android
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -Podr.abis=
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Uploads a deployment to the portal and leaves it there. Releasing it to
# Maven Central is a click in the portal UI, deliberately: Central never
# forgets a version, so this is the last point at which a bad artifact can
# still be dropped instead of lived with.
- name: publish to maven central
working-directory: android
# `shell: bash` for the pipefail it sets - the default `bash -e` would
# let tee's exit code hide a failing gradle
shell: bash
run: ./gradlew publishToMavenCentral -Podr.abis= | tee "${RUNNER_TEMP}/publish.log"
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASS }}
# The step above exits 0 however the portal judges the bundle, so without
# this a release central rejected looks like one that worked.
- name: await central validation
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
run: .github/scripts/await-central-validation.sh "${RUNNER_TEMP}/publish.log"