Skip to content

Commit dc26675

Browse files
authored
Merge pull request #379 from domaframework/release-script
Don't replace the version with the snapshot version in documents
2 parents 928c67c + 4b26f8a commit dc26675

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

build.gradle.kts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ plugins {
77
}
88

99
val encoding: String by project
10-
val isSnapshot = project.version.toString().endsWith("SNAPSHOT")
10+
val isSnapshot = version.toString().endsWith("SNAPSHOT")
11+
val releaseVersion = properties["release.releaseVersion"].toString()
12+
val newVersion = properties["release.newVersion"].toString()
1113
val secretKeyRingFile: String? =
1214
findProperty("signing.secretKeyRingFile")?.toString()?.let {
1315
if (it.isEmpty()) null
1416
else file(it).absolutePath
1517
}
1618

17-
fun replaceVersionArtifactClass() {
19+
fun replaceVersionInArtifact(ver: String) {
1820
ant.withGroovyBuilder {
1921
"replaceregexp"("match" to """(private static final String VERSION = ")[^"]*(")""",
20-
"replace" to "\\1${version}\\2",
22+
"replace" to "\\1${ver}\\2",
2123
"encoding" to encoding,
2224
"flags" to "g") {
2325
"fileset"("dir" to ".") {
@@ -43,14 +45,14 @@ subprojects {
4345

4446
extra["signing.secretKeyRingFile"] = secretKeyRingFile
4547

46-
val replaceVersionJava by tasks.registering {
48+
val replaceVersionInJava by tasks.registering {
4749
doLast {
48-
replaceVersionArtifactClass()
50+
replaceVersionInArtifact(version.toString())
4951
}
5052
}
5153

5254
val compileJava by tasks.existing(JavaCompile::class) {
53-
dependsOn(tasks.named("replaceVersionJava"))
55+
dependsOn(replaceVersionInJava)
5456
options.encoding = encoding
5557
}
5658

@@ -176,26 +178,33 @@ subprojects {
176178
rootProject.apply {
177179
apply(from = "release.gradle")
178180

179-
val replaceVersion by tasks.registering {
180-
mustRunAfter(tasks.named("updateVersion"))
181-
doLast {
182-
replaceVersionArtifactClass()
183-
ant.withGroovyBuilder {
184-
"replaceregexp"("match" to """("org.seasar.doma:doma(-core|-processor)?:)[^"]*(")""",
185-
"replace" to "\\1${version}\\3",
186-
"encoding" to encoding,
187-
"flags" to "g") {
188-
"fileset"("dir" to ".") {
189-
"include"("name" to "README.md")
190-
"include"("name" to "docs/**/*.rst")
191-
}
181+
fun replaceVersionInDocs(ver: String) {
182+
ant.withGroovyBuilder {
183+
"replaceregexp"("match" to """("org.seasar.doma:doma(-core|-processor)?:)[^"]*(")""",
184+
"replace" to "\\1${ver}\\3",
185+
"encoding" to encoding,
186+
"flags" to "g") {
187+
"fileset"("dir" to ".") {
188+
"include"("name" to "README.md")
189+
"include"("name" to "docs/**/*.rst")
192190
}
193191
}
194192
}
195193
}
196194

197-
val commitNewVersion by tasks.existing {
195+
val replaceVersion by tasks.registering {
196+
replaceVersionInArtifact(releaseVersion)
197+
replaceVersionInDocs(releaseVersion)
198+
}
199+
200+
val release by tasks.existing {
198201
dependsOn(replaceVersion)
202+
}
203+
204+
val updateVersion by tasks.existing {
205+
doLast {
206+
replaceVersionInArtifact(newVersion)
207+
}
199208
}
200209

201210
configure<com.diffplug.gradle.spotless.SpotlessExtension> {

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ projectUrl=https://github.com/domaframework/doma
66
githubUrl[email protected]:domaframework/doma.git
77
sonatypeUsername=
88
sonatypePassword=
9+
release.useAutomaticVersion=true
10+
release.releaseVersion=2.30.1
11+
release.newVersion=2.30.2-SNAPSHOT

0 commit comments

Comments
 (0)