From 096d6f591b96a66ebf85b7565b1db6a4edbb0e94 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 9 Jul 2026 22:26:29 +0000 Subject: [PATCH] [Chore] (android-plugin): make versionCode monotonic within a month major*100 + minor collides for multiple releases in the same month, and Android refuses to install a package whose versionCode is not strictly greater than the installed one. Encode as year*1_000_000 + month*10_000 + monthly-revision (commits since the month start), so every build upgrades cleanly; the month weight dwarfs the per-month reset on rollover. Co-Authored-By: Claude Fable 5 --- android-plugin/app/build.gradle | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/android-plugin/app/build.gradle b/android-plugin/app/build.gradle index 28547d80..a7ce5f14 100644 --- a/android-plugin/app/build.gradle +++ b/android-plugin/app/build.gradle @@ -46,6 +46,21 @@ def mobileGlGitShortHash = { 'nogit' } }() +// Monthly revision: commits reachable from HEAD since the start of the +// version's month. Multiple releases in one month (calendar versioning ships +// several per month) each get a strictly larger versionCode; a new month +// bumps the minor and dwarfs any reset via the *10000 weight. +def mobileGlMonthlyRevision = { + try { + def since = String.format('%d-%02d-01T00:00:00', 2000 + mobileGlVersionMajor, mobileGlVersionMinor) + def proc = ['git', 'rev-list', '--count', "--since=${since}", 'HEAD'].execute(null, rootDir) + proc.waitFor() + def n = proc.in.text.trim() + (proc.exitValue() == 0 && n) ? n.toInteger() : 0 + } catch (Exception ignored) { + 0 + } +}() android { namespace 'top.mobilegl.plugin' @@ -55,7 +70,11 @@ android { defaultConfig { minSdk 26 targetSdk 34 - versionCode mobileGlVersionMajor * 100 + mobileGlVersionMinor + // year*1_000_000 + month*10_000 + monthly revision keeps versionCode + // strictly increasing across releases (monotonic within a month and + // across month/year rollovers), so every build is an installable + // upgrade. Max ~99_129999, well under Android's 2_100_000_000 ceiling. + versionCode mobileGlVersionMajor * 1000000 + mobileGlVersionMinor * 10000 + mobileGlMonthlyRevision versionName String.format('%d.%02d.%s', mobileGlVersionMajor, mobileGlVersionMinor, mobileGlGitShortHash) ndk {