diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-02-24 13:59:00 -0800 |
---|---|---|
committer | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-02-24 13:59:00 -0800 |
commit | 105a6a118b3b8e73e5b1e8c264e80987654904d7 (patch) | |
tree | 9f0c46c4e9888a1049ca3c62991a169fa9073c3d | |
parent | 6ec68733e0f1c6a2bbbbb4735e9c1f2de8cf6b8c (diff) | |
download | WorkMode-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.gradle | 4 | ||||
-rw-r--r-- | build.gradle | 16 |
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 |