$ gradle release -Prelease.releaseVersion=1.0.0 -Prelease.newVersion=1.1.0-SNAPSHOT
release {
project.ext.set("release.useAutomaticVersion", true)
git {
requireBranch = ''
}
failOnCommitNeeded = true
failOnPublishNeeded = true
failOnUnversionedFiles = true
buildTasks = ['build']
}
confirmReleaseVersion.doLast {
updateVersion("checkstyle.xml")
updateVersion(".editorconfig")
}
def updateVersion(fileName) {
def f = file("${rootDir}/$fileName")
def text = f.text
f.withWriter { w ->
w << text.replaceAll("(version: )\\d+\\.\\d+\\.\\d+", "\$1${version}")
}
}
release {
project.ext.set("release.useAutomaticVersion", true)
def rg = ~/(\d+)([^\d]*$)/
def m = rg.matcher(String.valueOf(project.version))
def v = m.replaceAll("${(m[0][1] as int) + 1}${m[0][2]}")
project.ext.set("release.releaseVersion", v)
project.ext.set("release.newVersion", v)
git {
requireBranch = 'main'
}
failOnCommitNeeded = false
failOnPublishNeeded = false
failOnUnversionedFiles = false
buildTasks = []
}
confirmReleaseVersion.doLast {
def f = file("${project.projectDir}/README.md")
def text = f.text
f.withWriter { w ->
w << text.replaceAll("(:\\ )*\\d+\\.\\d+\\.\\d+", "\$1${version}")
}
}
O lifecycle desse plugin é o seguinte:
Ou seja, o numero que foi gerado agora só será release na proxima geração de release, ex:
1.0.0
1.0.0
1.0.0
e commita na branch atualrelease {
git {
pushToRemote.set('') // disabling push to remote
}
}
Versão específica
./gradlew release -Prelease.releaseVersion=3.6.0 -Prelease.newVersion=3.6.1
gradle release commands, gradle release examples, gradle release bookmarks