Skip to content

Commit d058636

Browse files
committed
Execute the required processing within doLast.
1 parent fc709b9 commit d058636

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

.github/workflows/release-drafter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525

2626
update_version:
2727
needs: update_release_draft
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 30
2830
permissions:
2931
contents: write
3032
pull-requests: write
31-
runs-on: ubuntu-latest
32-
timeout-minutes: 30
3333

3434
steps:
3535
- name: Get latest draft release title

build.gradle.kts

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,7 @@ spotless {
545545
}
546546
}
547547

548-
val encoding: String by project
549-
550-
fun replaceVersionInPluginUtil(
551-
ver: String,
552-
encoding: String,
553-
) {
548+
fun replaceVersionInPluginUtil(ver: String) {
554549
ant.withGroovyBuilder {
555550
"replaceregexp"(
556551
"match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-beta)*)""",
@@ -565,10 +560,7 @@ fun replaceVersionInPluginUtil(
565560
}
566561
}
567562

568-
fun replaceVersionGradleProperty(
569-
ver: String,
570-
encoding: String,
571-
) {
563+
fun replaceVersionGradleProperty(ver: String) {
572564
ant.withGroovyBuilder {
573565
"replaceregexp"(
574566
"match" to """(pluginVersion = )(\d+\.\d+\.\d+)((?:-beta)*)""",
@@ -583,10 +575,7 @@ fun replaceVersionGradleProperty(
583575
}
584576
}
585577

586-
fun replaceVersionInLogSetting(
587-
ver: String,
588-
encoding: String,
589-
) {
578+
fun replaceVersionInLogSetting(ver: String) {
590579
ant.withGroovyBuilder {
591580
"replaceregexp"(
592581
"match" to """(org.domaframework.doma.intellij.plugin.version:-)(\d+\.\d+\.\d+)((?:-beta)*)(})""",
@@ -602,23 +591,16 @@ fun replaceVersionInLogSetting(
602591
}
603592
}
604593

605-
fun replaceVersion(
606-
ver: String,
607-
encoding: String,
608-
) {
594+
fun replaceVersion(ver: String) {
609595
checkNotNull(ver)
610-
replaceVersionInPluginUtil(ver, encoding)
611-
replaceVersionGradleProperty("$ver-beta", encoding)
612-
replaceVersionInLogSetting(ver, encoding)
596+
replaceVersionInPluginUtil(ver)
597+
replaceVersionGradleProperty("$ver-beta")
598+
replaceVersionInLogSetting(ver)
613599
println("Replace version in PluginUtil.kt, gradle.properties, logback.xml")
614-
615-
val githubEnv = System.getenv("GITHUB_ENV")
616-
val envFile = File(githubEnv)
617-
envFile.appendText("REPLACE_VERSION=$ver\n")
618-
619-
println("Set Replace version in GITHUB_ENV: $ver")
620600
}
621601

602+
val encoding: String by project
603+
622604
tasks.register("replaceNewVersion") {
623605
val releaseVersion =
624606
if (project.hasProperty("newVersion")) {
@@ -627,7 +609,6 @@ tasks.register("replaceNewVersion") {
627609
"0.0.0"
628610
}
629611

630-
val projectEncoding = encoding
631612
doLast {
632613
val lastVersions = releaseVersion.substringAfter("v").split(".")
633614
val major = lastVersions[0].toInt()
@@ -636,7 +617,16 @@ tasks.register("replaceNewVersion") {
636617

637618
val newVersion = "$major.$minor.$patch"
638619
println("Release newVersion: $newVersion")
639-
replaceVersion(newVersion, projectEncoding)
620+
replaceVersion(newVersion)
621+
try {
622+
val githubEnv = System.getenv("GITHUB_ENV")
623+
val envFile = File(githubEnv)
624+
envFile.appendText("REPLACE_VERSION=$newVersion\n")
625+
println("Set Replace version in GITHUB_ENV: $newVersion")
626+
} catch (e: NullPointerException) {
627+
println("GITHUB_ENV not found")
628+
println(e.stackTrace)
629+
}
640630
}
641631
}
642632

@@ -647,10 +637,18 @@ tasks.register("replaceDraftVersion") {
647637
} else {
648638
"0.0.0"
649639
}
650-
val projectEncoding = encoding
651640

652641
doLast {
653642
println("Release DraftVersion: $draftVersion")
654-
replaceVersion(draftVersion, projectEncoding)
643+
replaceVersion(draftVersion)
644+
try {
645+
val githubEnv = System.getenv("GITHUB_ENV")
646+
val envFile = File(githubEnv)
647+
envFile.appendText("REPLACE_VERSION=$draftVersion\n")
648+
println("Set Replace version in GITHUB_ENV: $draftVersion")
649+
} catch (e: NullPointerException) {
650+
println("GITHUB_ENV not found")
651+
println(e.stackTrace)
652+
}
655653
}
656654
}

0 commit comments

Comments
 (0)