From 230f8f3917e4e6fe9f376293c4727bfbea7cf1a4 Mon Sep 17 00:00:00 2001 From: nailyk Date: Fri, 10 May 2024 18:22:26 +0200 Subject: [PATCH] build.gradle: Always increase versionCode for Green MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Due to Android (and the F-Droid) upgrade process, `versionCode` should always increase in order to trigger the update process. Use a dedicated `versionCode` for Green releases, time base, which will always increase (beware of time zones ⚠️ ) Another side effect will be: the same code, rebuilt, will be considered as an upgrade, as build time will be newer. It is impossible to use the commit number as it is not an `int`. A better idea would be to count the amounts of commits, with something like `git rev-list --first-parent --count HEAD` but I didn't manage to do it. --- app/build.gradle | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index d53675dc4..a85ad3a13 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,6 +21,15 @@ final def CUSTOM_INSTANCE = "" // link to your support account. Will be linked on the about page when not empty. final def SUPPORT_ACCOUNT_URL = "https://mastodon.social/@Tusky" +/** + * Use the number of seconds/10 since Jan 1 2016 as the versionCode. + * This lets us upload a new build at most every 10 seconds for the + * next 680 years. + */ +def greenvcode = (int)(((new Date().getTime()/1000) - 1451606400) / 10) + + + android { compileSdk 34 namespace "com.keylesspalace.tusky" @@ -66,6 +75,8 @@ android { resValue "string", "app_name", APP_NAME + " Test" applicationIdSuffix ".test" versionNameSuffix "-" + gitSha + // Always use a bigger versionCode to trigger Android/F-Droid update process + versionCode greenvcode isDefault true } }