aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuutaW <17158086+Trumeet@users.noreply.github.com>2019-02-24 13:59:00 -0800
committerYuutaW <17158086+Trumeet@users.noreply.github.com>2019-02-24 13:59:00 -0800
commit105a6a118b3b8e73e5b1e8c264e80987654904d7 (patch)
tree9f0c46c4e9888a1049ca3c62991a169fa9073c3d
parent6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c (diff)
downloadWorkMode-105a6a118b3b8e73e5b1e8c264e80987654904d7.tar
WorkMode-105a6a118b3b8e73e5b1e8c264e80987654904d7.tar.gz
WorkMode-105a6a118b3b8e73e5b1e8c264e80987654904d7.tar.bz2
WorkMode-105a6a118b3b8e73e5b1e8c264e80987654904d7.zip
feat(app): read version from VCS
Signed-off-by: YuutaW <17158086+Trumeet@users.noreply.github.com>
-rw-r--r--app/build.gradle4
-rw-r--r--build.gradle16
2 files changed, 18 insertions, 2 deletions
diff --git a/app/build.gradle b/app/build.gradle
index bd8cf7d..d91aab1 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -18,8 +18,8 @@ android {
applicationId "moe.yuuta.workmode"
minSdkVersion 28
targetSdkVersion 28
- versionCode 1
- versionName "1.0"
+ versionCode rootProject.ext.versionCode
+ versionName rootProject.ext.versionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// Fabric
diff --git a/build.gradle b/build.gradle
index 5ec9780..17b7709 100644
--- a/build.gradle
+++ b/build.gradle
@@ -28,3 +28,19 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
+
+def gitCommitCount = 'git rev-list --count HEAD'.execute([], project.rootDir).text.trim()
+def version = "0.${gitCommitCount}"
+
+ext {
+ versionCode = Integer.parseInt("${gitCommitCount}")
+ versionName = "${version}"
+}
+
+task exportVersion(type: Exec) {
+ commandLine 'sh'
+ doLast {
+ file("$projectDir/version.txt").text = """$version"""
+ file("$projectDir/version_code.txt").text = """${gitCommitCount}"""
+ }
+} \ No newline at end of file