@@ -14,9 +14,10 @@ String composeBoMVersion = "2024.12.01"
14
14
15
15
def time = new Date ()
16
16
17
- def gitCommitCount = executeCmd(" git rev-list --count HEAD" )?. toInteger() ?: 1
18
- def gitLastTag = executeCmd(" git describe --tags --always" ) ?: " v0.0.0"
19
- def gitCommitId = executeCmd(" git rev-parse --short HEAD" ) ?: " nocommitid"
17
+ def gitCommitCount = executeCmd(" git rev-list --count HEAD" )?. toInteger() ?: 0
18
+ def gitCommitId = executeCmd(" git rev-parse --short HEAD" ) ?: " v0.0.0" //
19
+ def gitTag = executeCmd(" git tag --points-at HEAD" ). split(' \n ' )
20
+ def gitLastTag = executeCmd(" git describe --tags --always" ). split(" -" ). first() ?: " v0.0.0"
20
21
21
22
static def executeCmd (String cmd ) {
22
23
try {
@@ -65,7 +66,7 @@ android {
65
66
// 指定应用在运行时目标的 Android 版本。不影响可以使用的 API,而是影响应用在运行时的行为
66
67
targetSdk 35
67
68
versionCode gitCommitCount
68
- versionName gitLastTag // 假如每个 tag 都是一个 release
69
+ versionName gitLastTag
69
70
70
71
multiDexEnabled true
71
72
@@ -116,6 +117,7 @@ android {
116
117
// https://developer.android.com/build/build-variants
117
118
buildTypes {
118
119
debug {
120
+ versionNameSuffix " .${ gitCommitId} "
119
121
debuggable true // 可调试
120
122
minifyEnabled false // 代码压缩 (R8/ProGuard)
121
123
shrinkResources false // 资源压缩 (shrinkResources)
@@ -139,7 +141,7 @@ android {
139
141
// "_${variant.versionCode}" +
140
142
// "_${variant.buildType.name}" +
141
143
// "_${flavorType}" +
142
- " _${ gitCommitId} " +
144
+ // "_${gitCommitId}" +
143
145
// "_${time.time}" +
144
146
" .apk" )
145
147
println (" ${ flavorType} outputFileName = ${ name} " )
@@ -159,7 +161,7 @@ android {
159
161
// github
160
162
dimension " channel"
161
163
applicationIdSuffix " .github"
162
- versionNameSuffix " _github "
164
+ versionNameSuffix " .github "
163
165
manifestPlaceholders = [app_channel : " \" ${ name} \" " ]
164
166
buildConfigField " String" , " APP_CHANNEL" , " \" ${ name} \" "
165
167
}
0 commit comments