From 8a4fe3be8617d3472cb120c92225e0d0357994db Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Wed, 4 Nov 2020 19:46:28 +0200 Subject: [PATCH] Take version from the env variables --- app/build.gradle | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8258ba8..2ed5407 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,9 +18,35 @@ android { applicationId "com.artemchep.pocketmode" minSdkVersion 28 targetSdkVersion 29 - versionCode 17 - versionName "1.4.4" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + + def versionTag = System.getenv("POCKET_MODE_RELEASE_TAG") + ?: "0.1.0-0" + + def versionPartsCount = 4 + def versionParts = { + def l = it + .split(/[^0-9]+/) + .collect { + try { + it as int + } catch (Exception ignored) { + null + } + } + .findAll { it != null } + l += [0] * versionPartsCount + l.take(versionPartsCount) + }(versionTag) + + versionCode = versionParts + .withIndex() + .collect { v, index -> + def reverseIndex = versionParts.size - index - 1 + v * Math.pow(100, reverseIndex) as int + } + .sum() + versionName = versionParts.join('.') } signingConfigs { release {