From 8fb079612b881c1a61a8629a23c9c3791580f7ab Mon Sep 17 00:00:00 2001 From: xterao Date: Fri, 18 Apr 2025 15:04:18 +0900 Subject: [PATCH 1/7] When updating CHANGELOG.md, update version information such as log settings along with the plugin version. --- build.gradle.kts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8a58df59..b3ba1b59 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -387,11 +387,11 @@ tasks.register("updateChangelog") { } } - val newVersion = versionInfo.getNewVersion() + val releaseVersion = versionInfo.getNewVersion() val prLinks = mutableListOf() val newEntry = StringBuilder() - newEntry.append("## [$newVersion] - $releaseDate\n\n") + newEntry.append("## [$releaseVersion] - $releaseDate\n\n") categories.keys.forEach { category -> val hitItems = categorized[category] if (!hitItems.isNullOrEmpty()) { @@ -415,18 +415,18 @@ tasks.register("updateChangelog") { } val repoUrl = "https://github.com/domaframework/doma-tools-for-intellij" changelogFile.writeText(updatedContent) - changelogFile.appendText("[$newVersion]: $repoUrl/compare/$lastTag...$newVersion\n") + changelogFile.appendText("[$releaseVersion]: $repoUrl/compare/$lastTag...$releaseVersion\n") // Update Version Gradle pluginVersion - replaceVersionGradleProperty(newVersion) - println("Update Gradle Property: $newVersion") + replaceVersion(releaseVersion) + println("Update Version Pre Release: $releaseVersion") val githubEnv = System.getenv("GITHUB_ENV") val envFile = File(githubEnv) - envFile.appendText("NEW_VERSION=$newVersion\n") - envFile.appendText("BRANCH=doc/changelog-update-$newVersion\n") + envFile.appendText("NEW_VERSION=$releaseVersion\n") + envFile.appendText("BRANCH=doc/changelog-update-$releaseVersion\n") - println("Update newVersion: $newVersion") + println("Update newVersion: $releaseVersion") } } @@ -542,7 +542,7 @@ spotless { fun replaceVersionInPluginUtil(ver: String) { ant.withGroovyBuilder { "replaceregexp"( - "match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-beta)*)""", + "match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-\S+)*)""", "replace" to "\\1$ver", "encoding" to encoding, "flags" to "g", @@ -557,7 +557,7 @@ fun replaceVersionInPluginUtil(ver: String) { fun replaceVersionGradleProperty(ver: String) { ant.withGroovyBuilder { "replaceregexp"( - "match" to """(pluginVersion = )(\d+\.\d+\.\d+)((?:-beta)*)""", + "match" to """(pluginVersion = )(\d+\.\d+\.\d+)((?:-\S+)*)""", "replace" to "\\1$ver", "encoding" to encoding, "flags" to "g", @@ -572,7 +572,7 @@ fun replaceVersionGradleProperty(ver: String) { fun replaceVersionInLogSetting(ver: String) { ant.withGroovyBuilder { "replaceregexp"( - "match" to """(org.domaframework.doma.intellij.plugin.version:-)(\d+\.\d+\.\d+)((?:-beta)*)(})""", + "match" to """(org.domaframework.doma.intellij.plugin.version:-)(\d+\.\d+\.\d+)((?:-\S+)*)(})""", "replace" to "\\1$ver\\4", "encoding" to encoding, "flags" to "g", @@ -588,7 +588,7 @@ fun replaceVersionInLogSetting(ver: String) { fun replaceVersion(ver: String) { checkNotNull(ver) replaceVersionInPluginUtil(ver) - replaceVersionGradleProperty("$ver-beta") + replaceVersionGradleProperty(ver) replaceVersionInLogSetting(ver) println("Replace version in PluginUtil.kt, gradle.properties, logback.xml") } @@ -609,7 +609,7 @@ tasks.register("replaceNewVersion") { val minor = lastVersions[1].toInt() val patch = lastVersions[2].toInt() + 1 - val newVersion = "$major.$minor.$patch" + val newVersion = "$major.$minor.$patch-beta" println("Release newVersion: $newVersion") replaceVersion(newVersion) try { @@ -634,7 +634,7 @@ tasks.register("replaceDraftVersion") { doLast { println("Release DraftVersion: $draftVersion") - replaceVersion(draftVersion) + replaceVersion("$draftVersion-beta") try { val githubEnv = System.getenv("GITHUB_ENV") val envFile = File(githubEnv) From 45da08f20839ca30cc523882d8d3a6ac9df48daa Mon Sep 17 00:00:00 2001 From: xterao Date: Fri, 18 Apr 2025 18:10:09 +0900 Subject: [PATCH 2/7] Prevent update_version job from running on changelog update branches --- .github/workflows/release-drafter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index d7985521..b3cbe5ba 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,6 +10,7 @@ on: jobs: update_release_draft: + if: "! (github.head_ref =~ '^doc/changelog-update-\\d+\\.\\d+\\.\\d+$')" permissions: contents: write pull-requests: write @@ -25,6 +26,7 @@ jobs: update_version: needs: update_release_draft + if: "! (github.head_ref =~ '^doc/changelog-update-\\d+\\.\\d+\\.\\d+$')" runs-on: ubuntu-latest timeout-minutes: 30 permissions: From 172e1d48badec6fa2f5a72b3e76f17c7dc1ddaa7 Mon Sep 17 00:00:00 2001 From: xterao Date: Mon, 21 Apr 2025 13:32:24 +0900 Subject: [PATCH 3/7] Fix version replacement in build.gradle.kts to include closing quote --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b3ba1b59..f0d0f5a7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -543,7 +543,7 @@ fun replaceVersionInPluginUtil(ver: String) { ant.withGroovyBuilder { "replaceregexp"( "match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-\S+)*)""", - "replace" to "\\1$ver", + "replace" to "\\1$ver\"", "encoding" to encoding, "flags" to "g", ) { From d32e52eb78ac91a49a04ea102116a6a8d596cd42 Mon Sep 17 00:00:00 2001 From: xterao Date: Mon, 21 Apr 2025 13:33:54 +0900 Subject: [PATCH 4/7] Refactor condition for update_release_draft and update_version jobs to use contains function --- .github/workflows/release-drafter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index b3cbe5ba..ce37e0d5 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,7 +10,7 @@ on: jobs: update_release_draft: - if: "! (github.head_ref =~ '^doc/changelog-update-\\d+\\.\\d+\\.\\d+$')" + if: ${{ !contains(github.head_ref, 'doc/changelog-update-') }} permissions: contents: write pull-requests: write @@ -26,7 +26,7 @@ jobs: update_version: needs: update_release_draft - if: "! (github.head_ref =~ '^doc/changelog-update-\\d+\\.\\d+\\.\\d+$')" + if: ${{ !contains(github.head_ref, 'doc/changelog-update-') }} runs-on: ubuntu-latest timeout-minutes: 30 permissions: From 7077c7b5fbe5ebd9c0855e855296ffcd71a8a632 Mon Sep 17 00:00:00 2001 From: xterao Date: Mon, 21 Apr 2025 13:51:10 +0900 Subject: [PATCH 5/7] Fix regex in replaceVersionInPluginUtil to include closing quote for PLUGIN_VERSION --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f0d0f5a7..45747be1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -542,7 +542,7 @@ spotless { fun replaceVersionInPluginUtil(ver: String) { ant.withGroovyBuilder { "replaceregexp"( - "match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-\S+)*)""", + "match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-\S+)*)(")""", "replace" to "\\1$ver\"", "encoding" to encoding, "flags" to "g", From 0b5b36f387d5c5ceacbf22e84d0625c5af8c84a0 Mon Sep 17 00:00:00 2001 From: xterao Date: Mon, 21 Apr 2025 14:04:51 +0900 Subject: [PATCH 6/7] Add check for changelog update commits to skip job execution --- .github/workflows/release-drafter.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index ce37e0d5..aa56fb28 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -16,8 +16,19 @@ jobs: pull-requests: write runs-on: ubuntu-latest timeout-minutes: 30 + outputs: + skip_job: ${{ steps.check.outputs.SKIP_JOB }} steps: + - name: Check Commit Message + id: check + run: | + if [[ "${{ github.event.head_commit.message }}" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ ${{ github.repository_owner }}/doc/changelog-update-.*$ ]]; then + echo "This commit is not target. Skip the workflow." + echo "SKIP_JOB=true" >> $GITHUB_OUTPUT + else + echo "SKIP_JOB=false" >> $GITHUB_OUTPUT + fi - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -26,7 +37,7 @@ jobs: update_version: needs: update_release_draft - if: ${{ !contains(github.head_ref, 'doc/changelog-update-') }} + if: ${{ needs.update_release_draft.outputs.skip_job != 'true' }} runs-on: ubuntu-latest timeout-minutes: 30 permissions: From 2662bbf127f1226f55fa39191b6f0331a6f13f2d Mon Sep 17 00:00:00 2001 From: xterao <72187180+xterao@users.noreply.github.com> Date: Mon, 21 Apr 2025 14:16:02 +0900 Subject: [PATCH 7/7] Cleaned up commit message checking process Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/release-drafter.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index aa56fb28..ed2dd063 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -23,7 +23,10 @@ jobs: - name: Check Commit Message id: check run: | - if [[ "${{ github.event.head_commit.message }}" =~ ^Merge\ pull\ request\ #[0-9]+\ from\ ${{ github.repository_owner }}/doc/changelog-update-.*$ ]]; then + # Define a regex pattern to match commit messages for changelog updates + CHANGELOG_UPDATE_PATTERN="^Merge pull request #[0-9]+ from ${{ github.repository_owner }}/doc/changelog-update-.*$" + + if [[ "${{ github.event.head_commit.message }}" =~ $CHANGELOG_UPDATE_PATTERN ]]; then echo "This commit is not target. Skip the workflow." echo "SKIP_JOB=true" >> $GITHUB_OUTPUT else