Repository navigation
326 lines (284 loc) · 11.8 KB
/
Copy pathandroid.yml
File metadata and controls
326 lines (284 loc) · 11.8 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: Android Release CI
on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/android.yml'
- 'build.gradle'
- 'settings.gradle'
- 'gradle.properties'
- 'gradle/**'
- 'app/build.gradle'
- 'app/src/main/assets/**'
- 'app/src/main/java/com/kazumaproject/markdownhelperkeyboard/converter/compact/**'
- 'app/src/main/java/com/kazumaproject/markdownhelperkeyboard/dictionary_override/**'
- 'app/src/test/java/com/kazumaproject/markdownhelperkeyboard/converter/compact/**'
- 'tools/release/**'
- 'tools/classified-dictionaries/**'
push:
tags:
- 'v*'
permissions:
contents: write
concurrency:
group: android-release-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
env:
ZENZ_MODEL_CACHE_DIR: ${{ github.workspace }}/.zenz-model-cache
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
fetch-depth: 0
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Android SDK
uses: android-actions/setup-android@v4
with:
log-accepted-android-sdk-licenses: true
- name: Install Android API 37 and release NDK
run: sdkmanager "platforms;android-37.0" "build-tools;36.0.0" "ndk;29.0.14206865"
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache Zenz model
uses: actions/cache@v4
with:
path: .zenz-model-cache
key: ${{ runner.os }}-zenz-model-v2-4f5423f0fad41a73b1242eb96fe5c12ae4fdca83-Q5_K_M-ggml-model-Q5_K_M.gguf
- name: Decode JKS from Base64
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > my-release-key.jks
- name: Add signing info to local.properties
run: |
if [ ! -f local.properties ]; then
touch local.properties
fi
KEYSTORE_PATH=$(pwd)/my-release-key.jks
echo "# --- SigningConfig for CI ---" >> local.properties
echo "KEYSTORE_FILE=$KEYSTORE_PATH" >> local.properties
echo "KEYSTORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}" >> local.properties
echo "KEY_ALIAS=${{ secrets.KEY_ALIAS }}" >> local.properties
echo "KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}" >> local.properties
- name: Verify dictionary distribution and notices
run: python3 tools/classified-dictionaries/prepare.py --check
- name: Build Release Variants
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
./gradlew clean \
:app:assembleFullStandardRelease \
-PsplitApks \
--stacktrace \
--no-daemon \
--max-workers=1
./gradlew :app:assembleLiteStandardRelease \
-PsplitApks \
--stacktrace \
--no-daemon \
--max-workers=1
python3 tools/release/verify-lite-apk.py app/build/outputs/apk/liteStandard/release/*.apk
- name: Build and verify Play bundle native symbols
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
./gradlew :app:bundleFullStandardRelease --stacktrace --no-daemon --max-workers=1
python3 tools/release/verify-native-symbols.py app/build/outputs/bundle/fullStandardRelease/app-full-standard-release.aab
./gradlew :app:bundleLiteStandardRelease --stacktrace --no-daemon --max-workers=1
./gradlew -I tools/licenses/export-release.init.gradle :app:exportLicenseDependencies --no-configuration-cache --no-daemon --max-workers=1
python3 tools/licenses/prepare-libraries.py build/reports/licenses/resolved-release.json --check
- name: Upload signed internal test bundles
uses: actions/upload-artifact@v4
with:
name: internal-test-bundles-${{ github.sha }}
retention-days: 7
if-no-files-found: error
path: |
app/build/outputs/bundle/fullStandardRelease/*.aab
app/build/outputs/bundle/liteStandardRelease/*.aab
- name: Upload standard APKs for source verification
uses: actions/upload-artifact@v4
with:
name: standard-apks-${{ github.sha }}
if-no-files-found: error
path: |
app/build/outputs/apk/fullStandard/release/*.apk
app/build/outputs/apk/liteStandard/release/*.apk
fdroid:
runs-on: ubuntu-latest
strategy:
matrix:
build: [first, second]
steps:
- name: Checkout the exact workflow commit
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Android SDK
uses: android-actions/setup-android@v4
- name: Install Android API 37 and release build tools
run: sdkmanager "platforms;android-37.0" "build-tools;36.0.0" "ndk;29.0.14206865"
- name: Verify release source guard
run: python3 -m unittest discover -s tools/release
- name: Build unsigned F-Droid APK without restored caches
env:
# Each runner starts with a fresh checkout and an empty Gradle user home.
GRADLE_USER_HOME: ${{ runner.temp }}/fdroid-gradle-${{ matrix.build }}
# Use the release variant F-Droid builds, with no signing configuration.
# releaseUnsigned has a different BuildConfig.BUILD_TYPE.
run: |
./gradlew clean :app:assembleLiteFdroidRelease \
--no-build-cache --no-configuration-cache \
--stacktrace --no-daemon --max-workers=1
python3 tools/release/verify-release-source.py --revision "$GITHUB_SHA" \
app/build/outputs/apk/liteFdroid/release/app-liteFdroid-release.apk
python3 tools/release/verify-lite-apk.py \
app/build/outputs/apk/liteFdroid/release/app-liteFdroid-release.apk
- name: Test English dictionary decoding
env:
GRADLE_USER_HOME: ${{ runner.temp }}/fdroid-gradle-${{ matrix.build }}
run: |
./gradlew :app:testLiteFdroidDebugUnitTest \
--tests '*BundledEnglishDictionaryReaderTest' \
--tests '*MappedDictionaryAssetCacheTest' \
--no-daemon --max-workers=1
- name: Upload unsigned F-Droid APK for comparison
uses: actions/upload-artifact@v4
with:
name: fdroid-unsigned-${{ matrix.build }}-${{ github.sha }}
if-no-files-found: error
path: app/build/outputs/apk/liteFdroid/release/app-liteFdroid-release.apk
verify-fdroid:
needs: fdroid
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: fdroid-unsigned-first-${{ github.sha }}
path: fdroid/first
- uses: actions/download-artifact@v4
with:
name: fdroid-unsigned-second-${{ github.sha }}
path: fdroid/second
- name: Require identical clean F-Droid builds
run: cmp fdroid/first/app-liteFdroid-release.apk fdroid/second/app-liteFdroid-release.apk
publish:
if: github.event_name != 'pull_request'
needs: [build, fdroid, verify-fdroid]
runs-on: ubuntu-latest
steps:
- name: Checkout verification tools from the workflow commit
uses: actions/checkout@v5
with:
ref: ${{ github.sha }}
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Android SDK
uses: android-actions/setup-android@v4
- name: Install APK signing tools
run: sdkmanager "build-tools;36.0.0"
- name: Set up Python for F-Droid signature verification
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install F-Droid signature comparison tool
run: python -m pip install apksigcopier==1.1.1
- uses: actions/download-artifact@v4
with:
name: standard-apks-${{ github.sha }}
path: release/standard
- uses: actions/download-artifact@v4
with:
name: fdroid-unsigned-first-${{ github.sha }}
path: fdroid/first
- uses: actions/download-artifact@v4
with:
name: fdroid-unsigned-second-${{ github.sha }}
path: fdroid/second
- name: Require identical clean F-Droid builds
run: cmp fdroid/first/app-liteFdroid-release.apk fdroid/second/app-liteFdroid-release.apk
- name: Sign the verified F-Droid APK
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
key_store="$RUNNER_TEMP/fdroid-release.jks"
trap 'rm -f "$key_store"' EXIT
printf '%s' "$KEYSTORE_BASE64" | base64 -d > "$key_store"
"$ANDROID_HOME/build-tools/36.0.0/zipalign" -P 16 -f 4 \
fdroid/first/app-liteFdroid-release.apk "$RUNNER_TEMP/fdroid-aligned.apk"
"$ANDROID_HOME/build-tools/36.0.0/apksigner" sign \
--ks "$key_store" --ks-pass env:KEYSTORE_PASSWORD \
--ks-key-alias "$KEY_ALIAS" --key-pass env:KEY_PASSWORD \
--v1-signing-enabled false --v2-signing-enabled true \
--v3-signing-enabled false --v4-signing-enabled false \
--alignment-preserved true \
--out release/app-liteFdroid-release.apk "$RUNNER_TEMP/fdroid-aligned.apk"
"$ANDROID_HOME/build-tools/36.0.0/apksigner" verify release/app-liteFdroid-release.apk
- name: Verify the signed APK against the independent F-Droid rebuild
run: |
export PATH="$ANDROID_HOME/build-tools/36.0.0:$PATH"
apksigcopier compare --unsigned \
release/app-liteFdroid-release.apk fdroid/second/app-liteFdroid-release.apk
- name: Check APK revisions and the public tag for tag builds
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
mapfile -d '' apks < <(find release -name '*.apk' -print0)
source_args=(--revision "$GITHUB_SHA")
if [[ "$GITHUB_REF_TYPE" == tag ]]; then
source_args+=(--tag "$RELEASE_TAG")
fi
python3 tools/release/verify-release-source.py \
"${source_args[@]}" "${apks[@]}"
- name: Refuse to replace assets of an existing release
if: startsWith(github.ref, 'refs/tags/')
uses: actions/github-script@v7
with:
script: |
let release;
try {
release = await github.rest.repos.getReleaseByTag({
...context.repo, tag: context.ref.replace('refs/tags/', '')
});
} catch (error) {
if (error.status !== 404) throw error;
}
if (release && release.data.assets.length > 0) {
throw new Error('Release already has assets. Publish changes with a new version/tag.');
}
- name: Create Release and Upload Verified APKs
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
generate_release_notes: true
overwrite_files: false
files: release/**/*.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}