Skip to content

Commit 2935dfa

Browse files
authored
Improve release #656
There were still some minor nuisances in the script: * the error output of `git checkout` was swallowed * the version was updated before the branch was switched This should be fixed now.
2 parents f732d8d + 9079d81 commit 2935dfa

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

build-steps/release/publish.gradle

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,34 @@ def updateVersion = { Closure<String> calculateNewVersion ->
126126

127127
def 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

134141
task 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 $currentVersion in file ${file.absolutePath}"
148-
file.text = file.text.replaceAll(lastReleaseVersion, currentVersion)
155+
println "Replacing last release version $lastReleaseVersion by $releaseVersion in file ${file.absolutePath}"
156+
file.text = file.text.replaceAll(lastReleaseVersion, releaseVersion)
149157
}
150158
}
151159
}

0 commit comments

Comments
 (0)