1. ReleaseGit
'releaseGit',
{
def releaseVersion = PropertiesUtils.getSystemProperty("VERSION", (project.version as String) - '-SNAPSHOT')
def releaseBranch = "release/${project.versionId}-$releaseVersion"
def matcher
def newVersion
try {
matcher = releaseVersion =~ /(\d+)([^\d]*$)/
newVersion = PropertiesUtils.getSystemProperty("NEW_VERSION", matcher.replaceAll("${(matcher[0][1] as int) + 1}${matcher[0][2]}")) - "-SNAPSHOT" + "-SNAPSHOT"
} catch (Exception ignored) {
throw new GradleException("ReleaseGitFLow only support semantic version (Ex: 1.0.0)")
}
//Use 'false' value to skip merge to base branch
def baseBranch = PropertiesUtils.getSystemProperty("BASE_BRANCH", 'master')
def workBranch = PropertiesUtils.getSystemProperty("BRANCH", 'develop')
def newVersionId = Integer.parseInt(project.versionId as String) + 1
branch workBranch
pull workBranch
step 'prepareReleaseBranch', "prepare branch $releaseBranch"
branch releaseBranch, true
step 'prepareVersion', "prepare version"
changeProperties releaseVersion
step 'generateVersionFiles', "generate version files"
step 'commitVersionFiles', "commit version files"
commit "chore(version): Update version to $releaseVersion", true
step 'build', 'build and archive'
build
discardChange
if (baseBranch != 'false') {
step 'stepMergeToBaseBranch', 'merge to base branch'
branch baseBranch
merge releaseBranch
push
}
step 'tagVersion', 'tag the commit'
tag "$project.artifact-$project.versionId-$releaseVersion"
pushTag
step 'updateVersion', "Update version to $newVersionId - $newVersion"
branch releaseBranch
changeProperties newVersion, newVersionId
commit "chore(version): Update to new version $newVersion and versionId $newVersionId", true
push
step 'mergeDevelop', "Merge release branch to $workBranch"
branch workBranch
merge releaseBranch
push
}
|
Note
|
To use it you have to set enableReleaseGitFlow = true in Delivery’s extension and call releaseGitFlow. |