ci(native): publish the Play-signed Android APK to liketrek/trek-android for installs outside Google Play

People who install apps from GitHub (Obtainium and the like) asked for the
Android app outside Google Play. After the Play upload, the release job now
fetches the universal APK Google Play builds of that same bundle, signed
with the Play app signing key, and publishes it with a checksum to
liketrek/trek-android: one release per app version, a newer build of the
same version replacing its APK. A phone can move between the Play install
and this APK without uninstalling, and Play Billing and push work in it
wherever Google Play services do.

It runs only inside the app builds that already happen, so a server release
without app changes publishes nothing. A build is held back while the app
needs a newer native API than the latest server release answers, so no APK
asks for a server that is not out yet. The APKs live in their own repository
so app releases never show up in the server's release list or update check.
This commit is contained in:
Maurice
2026-11-26 22:54:32 +01:00
parent d383d3527b
commit 2ea1c99e31
4 changed files with 246 additions and 2 deletions
+39
View File
@@ -0,0 +1,39 @@
import { appMinimumApi, mayPublish, serverApi, universalDownloadId } from './android-apk-release.mjs';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
const read = (path) => readFileSync(fileURLToPath(new URL(`../../${path}`, import.meta.url)), 'utf8');
describe('android-apk-release', () => {
it('reads the native API the app needs and the one the server answers from the real files', () => {
const appMinimum = appMinimumApi(read('client/src/native/serverAddress.ts'));
const answered = serverApi(read('server/src/nest/health/features.controller.ts'));
assert.ok(Number.isInteger(appMinimum) && appMinimum >= 1);
// A commit never needs more than the server it ships with.
assert.ok(answered >= appMinimum);
});
it('refuses to guess when a constant moved', () => {
assert.throws(() => appMinimumApi('export const MIN_API = 3;'), /MIN_NATIVE_API not found/);
assert.throws(() => serverApi('nativeApi = 3'), /nativeApi not found/);
});
it('holds back a build that needs a server not released yet', () => {
assert.equal(mayPublish(3, 3), true);
assert.equal(mayPublish(3, 4), true);
assert.equal(mayPublish(4, 3), false);
});
it('finds the universal APK in a generatedApks answer, and nothing in one without it', () => {
assert.equal(
universalDownloadId({ generatedApks: [{ generatedSplitApks: [{}] }, { generatedUniversalApk: { downloadId: 'abc' } }] }),
'abc',
);
assert.equal(universalDownloadId({ generatedApks: [{ generatedSplitApks: [{}] }] }), null);
assert.equal(universalDownloadId({}), null);
assert.equal(universalDownloadId(null), null);
});
});