From 0cd714dcd7e15fe6c96a8aabf8189be3ef4c1df8 Mon Sep 17 00:00:00 2001 From: Nullptr Date: Thu, 2 Feb 2023 22:06:58 +0800 Subject: [PATCH] Version tag --- build.gradle.kts | 19 +++++++++++++++++-- module/build.gradle.kts | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c696d24..ff1d7c4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import com.android.build.gradle.LibraryExtension +import java.io.ByteArrayOutputStream plugins { id("com.android.application") apply false @@ -10,14 +11,28 @@ buildscript { maven("https://plugins.gradle.org/m2/") } dependencies { + classpath("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r") classpath("org.mozilla.rust-android-gradle:plugin:0.9.3") } } +fun String.execute(currentWorkingDir: File = file("./")): String { + val byteOut = ByteArrayOutputStream() + project.exec { + workingDir = currentWorkingDir + commandLine = split("\\s".toRegex()) + standardOutput = byteOut + } + return String(byteOut.toByteArray()).trim() +} + +val gitCommitCount = "git rev-list HEAD --count".execute().toInt() +val gitCommitHash = "git rev-parse --verify --short HEAD".execute() + val moduleId by extra("zygisksu") val moduleName by extra("Zygisk on KernelSU") -val verName by extra("v4.0.0") -val verCode by extra(4000) +val verName by extra("v4-0.1.0") +val verCode by extra(gitCommitCount) val androidMinSdkVersion by extra(29) val androidTargetSdkVersion by extra(33) diff --git a/module/build.gradle.kts b/module/build.gradle.kts index c6db95e..9a7c4d6 100644 --- a/module/build.gradle.kts +++ b/module/build.gradle.kts @@ -42,7 +42,7 @@ androidComponents.onVariants { variant -> expand( "moduleId" to moduleId, "moduleName" to moduleName, - "versionName" to verName, + "versionName" to "$verName ($verCode)", "versionCode" to verCode, ) }