@@ -126,26 +126,34 @@ def updateVersion = { Closure<String> calculateNewVersion ->
126126
127127def executeCommand = { String command ->
128128 new StringBuilder (). with { output ->
129- command. split(' ' ). execute(). with { it. consumeProcessOutputStream(output); it }. waitFor()
129+ def error = new StringBuilder ()
130+ def exitCode = command. split(' ' ). execute()
131+ .with {
132+ it. consumeProcessOutputStream(output)
133+ it. consumeProcessErrorStream(error)
134+ it
135+ }. waitFor()
136+ assert exitCode == 0 : " Command '$command ' failed with exit code $exitCode : $error "
130137 output. toString(). trim()
131138 }
132139}
133140
134141task prepareRelease () {
135142 doFirst {
136- updateVersion { int oldMajor , int oldMinor , int oldPatch , String oldSuffix -> " $oldMajor . $oldMinor . $oldPatch " }
143+ String releaseVersion = withCurrentVersion { int oldMajor , int oldMinor , int oldPatch , String oldSuffix -> " $oldMajor . $oldMinor . $oldPatch " }
137144
138- String currentVersion = getCurrentVersion()
139- def releaseBranch = " release-$currentVersion "
145+ def releaseBranch = " release-$releaseVersion "
140146 executeCommand(" git checkout -b $releaseBranch " )
141147 String currentBranch = executeCommand(' git rev-parse --abbrev-ref HEAD' )
142148 assert currentBranch == releaseBranch: " Mismatch: Should be on branch $releaseBranch but current branch is $currentBranch "
143149
150+ updateVersion { major , minor , patch , suffix -> releaseVersion }
151+
144152 String lastReleaseVersion = getLastReleaseVersion()
145153 [' README.md' , ' docs/_data/navigation.yml' , ' docs/_pages/getting-started.md' ]. each {
146154 new File (project. rootDir, it). with { file ->
147- println " Replacing last release version $lastReleaseVersion by $c urrentVersion in file ${ file.absolutePath} "
148- file. text = file. text. replaceAll(lastReleaseVersion, currentVersion )
155+ println " Replacing last release version $lastReleaseVersion by $r eleaseVersion in file ${ file.absolutePath} "
156+ file. text = file. text. replaceAll(lastReleaseVersion, releaseVersion )
149157 }
150158 }
151159 }
0 commit comments