feat(android): auto-publish signed APK and AAR from CI
Some checks failed
ci / test (pull_request) Failing after 3m13s

Push to main that touches android/** builds a release APK + SDK AAR on
docker-amd64, verifies size/ABI/signature, and create-or-joins the Forgejo
release. Version is latest v*.*.* patch+1, or v0.1.0 when there are no tags.
Release signing uses repo secrets (ANDROID_KEYSTORE_*), not the debug key.
This commit is contained in:
Sirius DevOps 2026-09-12 00:54:17 -04:00
commit 1c4aaefb01
No known key found for this signature in database
4 changed files with 413 additions and 26 deletions

View file

@ -48,7 +48,7 @@ Or from the repo root, with checksums and an optional publish step:
```bash
scripts/build-android-local.sh # -> dist/onionwire-<v>-android-arm64-v8a.apk
PUBLISH_TAG=v0.3.0 scripts/build-android-local.sh
PUBLISH_TAG=v0.1.0 scripts/build-android-local.sh
```
## Decisions you should know about
@ -96,12 +96,20 @@ encrypted at rest; identity keys are not — that is the locked v1 posture.
### Signing
Both `debug` and `release` are signed with the **standard debug keystore**
(`~/.android/debug.keystore`, auto-created by AGP). This is what makes the
release APK installable for sideloading. It is **not** a Play upload key;
nothing here should be uploaded to Play. When a real upload key exists, put it
in `~/.gradle/gradle.properties` or CI secrets and reference it from
`signingConfigs` — never in this repository.
Release APKs are signed with a **repo-owned keystore**, not the debug key.
* CI reads `ANDROID_KEYSTORE_BASE64`, `ANDROID_KEYSTORE_PASSWORD`,
`ANDROID_KEY_ALIAS`, and `ANDROID_KEY_PASSWORD` from Forgejo repo secrets
and writes them to `~/.android/onionwire-release.env` for the build.
* Locally, `scripts/build-android-local.sh` sources that same env file if
present (`~/.android/onionwire-release.jks` + `.env`, mode 600). Local and
CI APKs then verify as the same cert and can upgrade in place.
* If the env file is missing, Gradle **warns** and signs with the debug
keystore so a laptop build still installs. CI sets
`ONIONWIRE_REQUIRE_RELEASE_KEY=true` and **fails closed** instead — a
per-machine debug key would make every CI APK uninstallable over the last.
* Never commit a keystore, password, or `android/local.properties`. This is
not a Play upload key; nothing here should be uploaded to Play.
### Release builds are not minified
@ -113,10 +121,17 @@ deobfuscation, not before.
## CI
`.forgejo/workflows/release.yml` runs on an aarch64 Linux container on the Pi.
It cannot build an APK. Android artifacts are built on a host with the SDK/NDK
via `scripts/build-android-local.sh`, exactly like the x86_64 Linux binary is
built via `scripts/build-release-local.sh`.
`.forgejo/workflows/android-release.yml` runs on `docker-amd64` (T480 dind).
Any push to `main` that touches `android/**` (or the local build script / this
workflow) builds `onionwire-<version>-android-arm64-v8a.apk` and
`onionwire-sdk-<version>.aar`, verifies them, and attaches them to the Forgejo
release for that tag. Version is the latest `v*.*.*` tag plus patch, or
**v0.1.0** when there are no tags. `versionName` matches the tag;
`versionCode` is `major*10000 + minor*100 + patch` (so 0.1.0 → 100).
`workflow_dispatch` with `dry_run=true` builds and checksums without creating
a tag or publishing. `scripts/build-android-local.sh` remains the offline
fallback; it does not create tags.
## Layout