diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad38249..9fed533 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,10 +47,21 @@ jobs: run: ./gradlew --no-daemon lintFullDebug continue-on-error: true + # The test build a tester installs (Actions › this run › Artifacts): debug-signed with the + # repository's public test key, so each one installs over the last. `full` is the one to + # use; `fdroid` is the same app without the updater. + - name: Name the test builds + run: | + mkdir test-builds + short="${GITHUB_SHA::7}" + cp app/build/outputs/apk/full/debug/app-full-debug.apk "test-builds/llembas-android-debug-$GITHUB_RUN_NUMBER-$short.apk" + cp app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk "test-builds/llembas-android-debug-$GITHUB_RUN_NUMBER-$short-fdroid.apk" + (cd test-builds && sha256sum *.apk > SHA256SUMS) + - uses: actions/upload-artifact@v4 with: - name: llembas-android-debug - path: app/build/outputs/apk/*/debug/*.apk + name: llembas-android-debug-${{ github.run_number }} + path: test-builds/ if-no-files-found: error - uses: actions/upload-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a63cc63..be973ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,4 +73,7 @@ jobs: GH_TOKEN: ${{ github.token }} run: | git tag -l --format='%(contents)' "$TAG" | sed '/-----BEGIN SSH SIGNATURE-----/,$d' > notes.md - gh release create "$TAG" --verify-tag --title "LLeMbas for Android $VERSION" --notes-file notes.md dist/* + # A `-beta.N` tag is a pre-release: never "Latest", never what /releases/latest hands out. + pre="" + case "$TAG" in *-*) pre="--prerelease" ;; esac + gh release create "$TAG" --verify-tag $pre --title "LLeMbas for Android $VERSION" --notes-file notes.md dist/* diff --git a/.gitignore b/.gitignore index e2437af..e5ab679 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ local.properties # A release key never goes in the repository (CI writes it from secrets) *.jks *.keystore +# ...except the public test key debug builds are signed with (see app/build.gradle.kts) +!/app/test-debug.keystore # IDEs .idea/ *.iml diff --git a/CHANGELOG.md b/CHANGELOG.md index b89d5c6..961eabc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,16 @@ is in alpha and releases come off `main`. ## [Unreleased] +### Added + +- **Test builds for every change**: each push to `dev` leaves an installable APK on the CI run, + signed with a public test key so a newer test build installs over an older one. The version + in Settings › About carries the run's number. + ### Changed +- A beta (`vX.Y.Z-beta.N`) is published on GitHub as a pre-release by itself. + - **Pinned to LLeMbas server 2.0.0-beta.4**: the contract, the theme and the strings come from that release. Nothing a person sees changes; the server's API is the same as in beta.1. diff --git a/README.md b/README.md index 276083d..acc0dc4 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,13 @@ and check it against `SHA256SUMS`. The `full` APK updates itself from llembas.eu one does not. Android 10 or newer; the instance must run LLeMbas server 2.0 or newer (an older one is refused at sign-in, with a sentence saying so). +**Test builds.** Every push to `dev` builds a debug APK: open the newest green run under +[Actions](https://github.com/LLeMbas/LLeMbas-Android/actions/workflows/ci.yml), download the +`llembas-android-debug-N` artifact (GitHub asks you to be signed in), unzip it and install the APK that does +not end in `-fdroid`. It is a separate app ("eu.llembas.android.debug") beside a released one, +signed with a public test key kept in this repository, so each test build installs over the one +before it -- and anyone could sign one, so take test builds only from this repository's runs. + If your instance uses a certificate from your own certificate authority, install that CA on the phone first (Settings › Security › Encryption & credentials › Install a certificate › CA certificate). The app trusts CAs you installed, as the browser does. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8c0ef29..8e08d37 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -39,6 +39,17 @@ android { } signingConfigs { + // Debug builds are signed with a *public* test key that lives in the repository, so the + // APK every CI run uploads installs over the one before it (a runner's own debug key is + // new each run, and Android refuses an update from a different signer). It signs only + // the `.debug` application id, never a release, and it is no secret: anyone can sign + // with it, so install a debug build only from this repository's CI. + getByName("debug") { + storeFile = file("test-debug.keystore") + storePassword = "android" + keyAlias = "androiddebugkey" + keyPassword = "android" + } releaseKey?.let { key -> create("release") { storeFile = file(key.getProperty("file")) @@ -58,7 +69,9 @@ android { } debug { applicationIdSuffix = ".debug" - versionNameSuffix = "-debug" + // CI's run number, so a tester can tell two test builds apart in Settings › About. + versionNameSuffix = "-debug" + (System.getenv("GITHUB_RUN_NUMBER")?.let { ".$it" } ?: "") + signingConfig = signingConfigs.getByName("debug") } } diff --git a/app/src/main/java/eu/llembas/android/update/Updater.kt b/app/src/main/java/eu/llembas/android/update/Updater.kt index 35d04eb..c1afd6f 100644 --- a/app/src/main/java/eu/llembas/android/update/Updater.kt +++ b/app/src/main/java/eu/llembas/android/update/Updater.kt @@ -37,7 +37,7 @@ class Updater(private val context: Context) { if (!it.isSuccessful) return@withContext context.getString(R.string.update_unreachable) LembasJson.decodeFromString(Latest.serializer(), it.body!!.string()) } - if (!newer(latest.version, BuildConfig.VERSION_NAME.removeSuffix("-debug"))) { + if (!newer(latest.version, BuildConfig.VERSION_NAME.substringBefore("-debug"))) { return@withContext context.getString(R.string.update_none) } if (!context.packageManager.canRequestPackageInstalls()) { diff --git a/app/test-debug.keystore b/app/test-debug.keystore new file mode 100644 index 0000000..a32ba24 Binary files /dev/null and b/app/test-debug.keystore differ