Skip to content

Commit

Permalink
Merge pull request #379 from domaframework/release-script
Browse files Browse the repository at this point in the history
Don't replace the version with the snapshot version in documents
  • Loading branch information
nakamura-to committed Apr 18, 2020
2 parents 928c67c + 4b26f8a commit dc26675
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
49 changes: 29 additions & 20 deletions build.gradle.kts
Expand Up @@ -7,17 +7,19 @@ plugins {
}

val encoding: String by project
val isSnapshot = project.version.toString().endsWith("SNAPSHOT")
val isSnapshot = version.toString().endsWith("SNAPSHOT")
val releaseVersion = properties["release.releaseVersion"].toString()
val newVersion = properties["release.newVersion"].toString()
val secretKeyRingFile: String? =
findProperty("signing.secretKeyRingFile")?.toString()?.let {
if (it.isEmpty()) null
else file(it).absolutePath
}

fun replaceVersionArtifactClass() {
fun replaceVersionInArtifact(ver: String) {
ant.withGroovyBuilder {
"replaceregexp"("match" to """(private static final String VERSION = ")[^"]*(")""",
"replace" to "\\1${version}\\2",
"replace" to "\\1${ver}\\2",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to ".") {
Expand All @@ -43,14 +45,14 @@ subprojects {

extra["signing.secretKeyRingFile"] = secretKeyRingFile

val replaceVersionJava by tasks.registering {
val replaceVersionInJava by tasks.registering {
doLast {
replaceVersionArtifactClass()
replaceVersionInArtifact(version.toString())
}
}

val compileJava by tasks.existing(JavaCompile::class) {
dependsOn(tasks.named("replaceVersionJava"))
dependsOn(replaceVersionInJava)
options.encoding = encoding
}

Expand Down Expand Up @@ -176,26 +178,33 @@ subprojects {
rootProject.apply {
apply(from = "release.gradle")

val replaceVersion by tasks.registering {
mustRunAfter(tasks.named("updateVersion"))
doLast {
replaceVersionArtifactClass()
ant.withGroovyBuilder {
"replaceregexp"("match" to """("org.seasar.doma:doma(-core|-processor)?:)[^"]*(")""",
"replace" to "\\1${version}\\3",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to ".") {
"include"("name" to "README.md")
"include"("name" to "docs/**/*.rst")
}
fun replaceVersionInDocs(ver: String) {
ant.withGroovyBuilder {
"replaceregexp"("match" to """("org.seasar.doma:doma(-core|-processor)?:)[^"]*(")""",
"replace" to "\\1${ver}\\3",
"encoding" to encoding,
"flags" to "g") {
"fileset"("dir" to ".") {
"include"("name" to "README.md")
"include"("name" to "docs/**/*.rst")
}
}
}
}

val commitNewVersion by tasks.existing {
val replaceVersion by tasks.registering {
replaceVersionInArtifact(releaseVersion)
replaceVersionInDocs(releaseVersion)
}

val release by tasks.existing {
dependsOn(replaceVersion)
}

val updateVersion by tasks.existing {
doLast {
replaceVersionInArtifact(newVersion)
}
}

configure<com.diffplug.gradle.spotless.SpotlessExtension> {
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Expand Up @@ -6,3 +6,6 @@ projectUrl=https://github.com/domaframework/doma
githubUrl=git@github.com:domaframework/doma.git
sonatypeUsername=
sonatypePassword=
release.useAutomaticVersion=true
release.releaseVersion=2.30.1
release.newVersion=2.30.2-SNAPSHOT

0 comments on commit dc26675

Please sign in to comment.