Skip to content

Instantly share code, notes, and snippets.

@mageddo
Last active March 14, 2023 01:21
Show Gist options
  • Save mageddo/c5c828594f91679ea47a42e6906b0d4d to your computer and use it in GitHub Desktop.
Save mageddo/c5c828594f91679ea47a42e6906b0d4d to your computer and use it in GitHub Desktop.
updating version at a file
confirmReleaseVersion.doLast {
println "> upgrading docker-compose version=${project.version}"
def versionPattern = "\\d+\\.\\d+\\.\\d+(?:-beta|-snapshot|-alpha)?"
updateVersion("README.md", "/${versionPattern}/", "/${version}/")
updateVersion("docker-compose.yml", "(image:.*:)(.*)", "\$1${project.version}")
def sout = new StringBuilder()
def proc = ['git', 'commit', '-a', "-m [Gradle Release Plugin] - releasing '${project.version}'."].execute()
proc.consumeProcessOutput(sout, sout)
proc.waitForOrKill(3000)
println "> $sout"
}
void updateVersion(f, pattern, replace){
f = file("${project.projectDir}}/${f}")
println "> updating version in: ${f}"
if(!f.exists()){
println "file ${f} not found"
System.exit(-1)
}
f.write(f.text.replaceAll(pattern, replace))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment