mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-28 07:30:04 +00:00
fix(native-release): publish the Android APK for release tags only
A prerelease tag or a run started by hand is a testing build on the internal track, so it no longer replaces the public APK in liketrek/trek-android.
This commit is contained in:
@@ -107,8 +107,9 @@ jobs:
|
||||
|
||||
# The same build for installs outside Google Play: the universal APK Google
|
||||
# Play makes of this bundle, signed with the Play app signing key, published
|
||||
# to liketrek/trek-android for Obtainium (wiki/Native-Apps.md). Held back
|
||||
# while the app needs a server version that is not released yet.
|
||||
# to liketrek/trek-android for Obtainium (wiki/Native-Apps.md). Only for a
|
||||
# release tag, and held back while the app needs a server version that is
|
||||
# not released yet.
|
||||
- name: Whether the latest server release serves this build
|
||||
id: released
|
||||
env:
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
// be cut from dev before the server it needs is released. It may go out
|
||||
// once the latest server release answers a nativeApi at least that high
|
||||
// (its server/src/nest/health/features.controller.ts, which the workflow
|
||||
// writes out with git show). Prints publish=true or publish=false, for
|
||||
// $GITHUB_OUTPUT.
|
||||
// writes out with git show). Only a release tag goes out (vX.Y.Z, pushed):
|
||||
// a prerelease tag or a run started by hand is a testing build. Prints
|
||||
// publish=true or publish=false, for $GITHUB_OUTPUT.
|
||||
//
|
||||
// download <service account json> <package> <version code> <out.apk>
|
||||
// Asks the Play Developer API for the universal APK of that version code,
|
||||
@@ -54,7 +55,17 @@ export function mayPublish(appMinimum, released) {
|
||||
return released >= appMinimum;
|
||||
}
|
||||
|
||||
/** Whether the run was started by pushing a release tag, not a prerelease tag or by hand. */
|
||||
export function isReleaseRun(eventName, ref) {
|
||||
return eventName === 'push' && /^refs\/tags\/v\d+\.\d+\.\d+$/.test(ref ?? '');
|
||||
}
|
||||
|
||||
function guard(releasedFeatures) {
|
||||
if (!isReleaseRun(process.env.GITHUB_EVENT_NAME, process.env.GITHUB_REF)) {
|
||||
console.error(`${process.env.GITHUB_REF} is not a release tag: hold back`);
|
||||
console.log('publish=false');
|
||||
return;
|
||||
}
|
||||
const appMinimum = appMinimumApi(readFileSync(APP_MIN_FILE, 'utf8'));
|
||||
const released = serverApi(readFileSync(releasedFeatures, 'utf8'));
|
||||
const publish = mayPublish(appMinimum, released);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { appMinimumApi, mayPublish, serverApi, universalDownloadId } from './android-apk-release.mjs';
|
||||
import { appMinimumApi, isReleaseRun, mayPublish, serverApi, universalDownloadId } from './android-apk-release.mjs';
|
||||
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
@@ -27,6 +27,15 @@ describe('android-apk-release', () => {
|
||||
assert.equal(mayPublish(4, 3), false);
|
||||
});
|
||||
|
||||
it('publishes only for a pushed release tag', () => {
|
||||
assert.equal(isReleaseRun('push', 'refs/tags/v5.2.2'), true);
|
||||
assert.equal(isReleaseRun('push', 'refs/tags/v5.2.2-tf.1'), false);
|
||||
assert.equal(isReleaseRun('push', 'refs/heads/dev'), false);
|
||||
assert.equal(isReleaseRun('workflow_dispatch', 'refs/tags/v5.2.2'), false);
|
||||
assert.equal(isReleaseRun('workflow_dispatch', 'refs/heads/dev'), false);
|
||||
assert.equal(isReleaseRun('push', undefined), false);
|
||||
});
|
||||
|
||||
it('finds the universal APK in a generatedApks answer, and nothing in one without it', () => {
|
||||
assert.equal(
|
||||
universalDownloadId({ generatedApks: [{ generatedSplitApks: [{}] }, { generatedUniversalApk: { downloadId: 'abc' } }] }),
|
||||
|
||||
Reference in New Issue
Block a user