Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@ on:

jobs:
update_release_draft:
if: ${{ !contains(github.head_ref, 'doc/changelog-update-') }}
permissions:
contents: write
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 }}
Expand All @@ -25,6 +37,7 @@ jobs:

update_version:
needs: update_release_draft
if: ${{ needs.update_release_draft.outputs.skip_job != 'true' }}
Copy link

Copilot AI Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Ensure the 'skip_job' output is always a string, as intended, to guarantee reliable comparison; consider coercing the output if necessary.

Suggested change
if: ${{ needs.update_release_draft.outputs.skip_job != 'true' }}
if: ${{ needs.update_release_draft.outputs.skip_job != "\"true\"" }}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logical type comparisons do not need to be enclosed in double quotes, so we will leave it as it is.

runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
Expand Down
30 changes: 15 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ tasks.register("updateChangelog") {
}
}

val newVersion = versionInfo.getNewVersion()
val releaseVersion = versionInfo.getNewVersion()
val prLinks = mutableListOf<String>()
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()) {
Expand All @@ -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")
}
}

Expand Down Expand Up @@ -542,8 +542,8 @@ spotless {
fun replaceVersionInPluginUtil(ver: String) {
ant.withGroovyBuilder {
"replaceregexp"(
"match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-beta)*)""",
"replace" to "\\1$ver",
"match" to """(const val PLUGIN_VERSION = ")(\d+\.\d+\.\d+)((?:-\S+)*)(")""",
"replace" to "\\1$ver\"",
"encoding" to encoding,
"flags" to "g",
) {
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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")
}
Expand All @@ -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 {
Expand All @@ -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)
Expand Down
Loading