summaryrefslogtreecommitdiff
path: root/org.fox.ttrss
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2025-05-05 17:09:14 +0300
committerAndrew Dolgov <fox@fakecake.org>2025-05-05 17:31:34 +0300
commit12cbbf3e55a982d361d5ad51d7494854157ff6c9 (patch)
tree572166d2fd9e444db75215e9fb2992aa0f2bdd1d /org.fox.ttrss
parent855ed5f8c6b61af2877da82406abeb94ca019d58 (diff)
use git-based version like tt-rss proper
Diffstat (limited to 'org.fox.ttrss')
-rwxr-xr-xorg.fox.ttrss/build.gradle47
1 files changed, 46 insertions, 1 deletions
diff --git a/org.fox.ttrss/build.gradle b/org.fox.ttrss/build.gradle
index b057a364..ab434f5e 100755
--- a/org.fox.ttrss/build.gradle
+++ b/org.fox.ttrss/build.gradle
@@ -15,7 +15,7 @@ android {
targetSdkVersion 31
compileSdkVersion 35
versionCode 558
- versionName "1.323"
+ versionName getVersion()
}
signingConfigs {
@@ -56,6 +56,51 @@ android {
}
}
+def getGitTimestamp() {
+ // gitlab CI iso-8601 timestamp
+ if (System.getenv("CI_COMMIT_TIMESTAMP")) {
+ return Date.parse("yyyy-MM-dd'T'HH:mm:ssXXX", System.getenv("CI_COMMIT_TIMESTAMP")).format('YY.MM')
+ }
+
+ // try to get version from git repo in current dir
+ try {
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine 'git', '--no-pager', 'log', '--pretty=%ct', '-n1', 'HEAD'
+ standardOutput = stdout
+ }
+
+ return new Date(stdout.toString().trim().toLong() * 1000).format('YY.MM')
+ }
+ catch (ignored) {
+ return 0;
+ }
+
+}
+
+def getGitCommitHash() {
+ // gitlab CI
+ if (System.getenv("CI_COMMIT_SHORT_SHA"))
+ return System.getenv("CI_COMMIT_SHORT_SHA");
+
+ // try to get version from git repo in current dir
+ try {
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine 'git', '--no-pager', 'log', '--pretty=%h', '-n1', 'HEAD'
+ standardOutput = stdout
+ }
+ return stdout.toString().trim()
+ }
+ catch (ignored) {
+ return 'UNKNOWN';
+ }
+}
+
+def getVersion() {
+ return getGitTimestamp() + '-' + getGitCommitHash();
+}
+
dependencies {
implementation 'com.squareup.okhttp3:okhttp:3.12.5'
implementation('com.github.bumptech.glide:okhttp3-integration:1.5.0') {