ci: support independent versioning per SDK module
- Add per-module version properties in gradle.properties (SDK_CORE_VERSION, SDK_LICENSE_VERSION, etc.) - Jenkinsfile bumps only selected modules independently - Print published module versions in post-build success step Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
这个提交包含在:
父节点
db3ec3d377
当前提交
60a7064eb2
56
Jenkinsfile
vendored
56
Jenkinsfile
vendored
@ -50,13 +50,8 @@ pipeline {
|
||||
stage('Resolve Versions') {
|
||||
steps {
|
||||
script {
|
||||
// Read version using pure Groovy (no Windows external commands)
|
||||
def props = readFile('gradle.properties')
|
||||
def verLine = props.readLines().find { it.trim().startsWith('PUBLISH_VERSION=') }
|
||||
def currentVer = verLine ? verLine.split('=', 2)[1].trim() : '0.1.0'
|
||||
echo "Current PUBLISH_VERSION: ${currentVer}"
|
||||
|
||||
def parts = currentVer.tokenize('.')
|
||||
def bumpVersion = { String ver ->
|
||||
def parts = ver.tokenize('.')
|
||||
while (parts.size() < 3) { parts.add('0') }
|
||||
def major = parts[0].toInteger()
|
||||
def minor = parts[1].toInteger()
|
||||
@ -66,23 +61,41 @@ pipeline {
|
||||
else if (params.VERSION_BUMP == 'minor') { minor++; patch = 0 }
|
||||
else { patch++ }
|
||||
|
||||
def newVer = "${major}.${minor}.${patch}"
|
||||
echo "Auto-bumped PUBLISH_VERSION: ${currentVer} → ${newVer}"
|
||||
env.NEW_VERSION = newVer
|
||||
return "${major}.${minor}.${patch}"
|
||||
}
|
||||
|
||||
// Write back using pure Groovy
|
||||
def newProps = props.replaceAll(/(?m)^PUBLISH_VERSION=.*/, "PUBLISH_VERSION=${newVer}")
|
||||
writeFile(file: 'gradle.properties', text: newProps)
|
||||
def propsText = readFile('gradle.properties')
|
||||
def getProp = { String key ->
|
||||
def line = propsText.readLines().find { it.trim().startsWith("${key}=") }
|
||||
return line ? line.split('=', 2)[1].trim() : null
|
||||
}
|
||||
def setProp = { String key, String value ->
|
||||
def pattern = /(?m)^${key}=.*/
|
||||
if (propsText =~ pattern) {
|
||||
propsText = propsText.replaceAll(pattern, "${key}=${value}")
|
||||
} else {
|
||||
propsText = propsText.trim() + "\n${key}=${value}\n"
|
||||
}
|
||||
}
|
||||
|
||||
def modules = env.PUBLISH_MODULES.split(',').toList()
|
||||
def versionMap = [:]
|
||||
def versionArgs = []
|
||||
def publishedVersions = []
|
||||
|
||||
for (mod in modules) {
|
||||
def propName = "SDK_${mod.replace('sdk-', '').toUpperCase()}_VERSION"
|
||||
versionMap[propName] = newVer
|
||||
def currentVer = getProp(propName) ?: getProp('PUBLISH_VERSION') ?: '0.1.0'
|
||||
def newVer = bumpVersion(currentVer)
|
||||
|
||||
setProp(propName, newVer)
|
||||
versionArgs.add("-P${propName}=${newVer}")
|
||||
publishedVersions.add("${mod}: ${currentVer} → ${newVer}")
|
||||
echo "${mod} version: ${currentVer} → ${newVer}"
|
||||
}
|
||||
env.VERSION_ARGS = versionMap
|
||||
.collect { k, v -> "-P${k}=${v}" }
|
||||
.join(' ')
|
||||
|
||||
writeFile(file: 'gradle.properties', text: propsText)
|
||||
env.VERSION_ARGS = versionArgs.join(' ')
|
||||
env.PUBLISHED_VERSIONS = publishedVersions.join('\n')
|
||||
echo "VERSION_ARGS: ${env.VERSION_ARGS}"
|
||||
}
|
||||
}
|
||||
@ -116,7 +129,7 @@ pipeline {
|
||||
git config user.email "jenkins@xuqm.com"
|
||||
git config user.name "Jenkins CI"
|
||||
git add gradle.properties
|
||||
git diff --cached --quiet || git commit -m "ci: bump PUBLISH_VERSION to ${env.NEW_VERSION}"
|
||||
git diff --cached --quiet || git commit -m "ci: bump module versions [${env.PUBLISH_MODULES}]"
|
||||
git push origin HEAD:main
|
||||
"""
|
||||
}
|
||||
@ -125,7 +138,10 @@ pipeline {
|
||||
}
|
||||
|
||||
post {
|
||||
success { echo "Android SDK 构建成功" }
|
||||
success {
|
||||
echo "Android SDK 构建成功"
|
||||
echo "发布版本:\n${env.PUBLISHED_VERSIONS}"
|
||||
}
|
||||
failure { echo "Android SDK 构建失败" }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +1,11 @@
|
||||
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8android.useAndroidX=truekotlin.code.style=officialandroid.nonTransitiveRClass=truePUBLISH_VERSION=1.0.5
|
||||
org.gradle.jvmargs=-Xmx4096m -Dfile.encoding=UTF-8
|
||||
android.useAndroidX=true
|
||||
kotlin.code.style=official
|
||||
android.nonTransitiveRClass=true
|
||||
PUBLISH_VERSION=1.0.5
|
||||
SDK_CORE_VERSION=1.0.5
|
||||
SDK_IM_VERSION=1.0.5
|
||||
SDK_PUSH_VERSION=1.0.5
|
||||
SDK_UPDATE_VERSION=1.0.5
|
||||
SDK_WEBVIEW_VERSION=1.0.5
|
||||
SDK_LICENSE_VERSION=1.0.5
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户