@@ -12,27 +12,70 @@ android {
1212 applicationId = " com.hotbell.radio"
1313 minSdk = 26
1414 targetSdk = 34
15- versionCode = 1
16- versionName = " 1.0"
15+
16+ // Git-based Versioning
17+ fun getGitCommitCount (): Int {
18+ return try {
19+ val process = ProcessBuilder (" git" , " rev-list" , " --count" , " HEAD" ).start()
20+ process.inputStream.bufferedReader().readText().trim().toInt()
21+ } catch (e: Exception ) {
22+ 1 // Fallback
23+ }
24+ }
25+
26+ fun getGitCommitHash (): String {
27+ return try {
28+ val process = ProcessBuilder (" git" , " rev-parse" , " --short" , " HEAD" ).start()
29+ process.inputStream.bufferedReader().readText().trim()
30+ } catch (e: Exception ) {
31+ " unknown"
32+ }
33+ }
34+
35+ val commitCount = getGitCommitCount()
36+ val commitHash = getGitCommitHash()
37+
38+ versionCode = commitCount
39+ versionName = " 1.$commitCount .$commitHash "
1740
1841 testInstrumentationRunner = " androidx.test.runner.AndroidJUnitRunner"
1942 vectorDrawables {
2043 useSupportLibrary = true
2144 }
2245 }
2346
47+ signingConfigs {
48+ create(" release" ) {
49+ storeFile = file(" release.jks" )
50+ storePassword = System .getenv(" SIGNING_STORE_PASSWORD" ) ? : " 123456"
51+ keyAlias = System .getenv(" SIGNING_KEY_ALIAS" ) ? : " key"
52+ keyPassword = System .getenv(" SIGNING_KEY_PASSWORD" ) ? : " 123456"
53+ }
54+ }
55+
2456 buildTypes {
2557 release {
2658 isMinifyEnabled = true
59+ isShrinkResources = true
2760 proguardFiles(getDefaultProguardFile(" proguard-android-optimize.txt" ), " proguard-rules.pro" )
61+ signingConfig = signingConfigs.getByName(" release" )
2862 }
2963 }
3064 compileOptions {
31- sourceCompatibility = JavaVersion .VERSION_17
32- targetCompatibility = JavaVersion .VERSION_17
65+ sourceCompatibility = JavaVersion .VERSION_21
66+ targetCompatibility = JavaVersion .VERSION_21
3367 }
3468 kotlinOptions {
35- jvmTarget = " 17"
69+ jvmTarget = " 21"
70+ }
71+
72+ applicationVariants.all {
73+ val variant = this
74+ variant.outputs
75+ .map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
76+ .forEach { output ->
77+ output.outputFileName = " HotBell-Radio-${variant.versionName} -${variant.name} .apk"
78+ }
3679 }
3780 buildFeatures {
3881 compose = true
0 commit comments