Skip to content

Commit 5092ca3

Browse files
authored
Merge pull request #103 from domaframework/fix/plugin-version-configure
Update changelog and improve version handling
2 parents d5f1f6a + a6b718d commit 5092ca3

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

.github/workflows/update_changelog.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
git config user.name "GitHub Action"
7878
git checkout -b $BRANCH
7979
git add CHANGELOG.md
80+
git add gradle.properties
8081
git commit -am "Changelog update - $NEW_VERSION"
8182
git push --set-upstream --force-with-lease origin $BRANCH
8283

build.gradle.kts

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
22
import com.fasterxml.jackson.annotation.JsonProperty
33
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
44
import org.gradle.internal.classpath.Instrumented.systemProperty
5-
import org.jetbrains.changelog.Changelog
65
import org.jetbrains.changelog.markdownToHTML
76
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
87
import java.net.URL
@@ -98,7 +97,7 @@ dependencies {
9897

9998
intellijPlatform {
10099
pluginConfiguration {
101-
version = providers.gradleProperty("pluginVersion").map { it.substringBefore('-', "") }
100+
version = providers.gradleProperty("pluginVersion")
102101
description =
103102
providers.fileContents(layout.projectDirectory.file("README.md")).asText.map {
104103
val start = "<!-- Plugin description -->"
@@ -108,26 +107,12 @@ intellijPlatform {
108107
if (!containsAll(listOf(start, end))) {
109108
throw GradleException("Plugin description section not found in README.md:\n$start ... $end")
110109
}
111-
subList(indexOf(start) + 1, indexOf(end)).joinToString("\n").let(::markdownToHTML)
110+
subList(indexOf(start) + 1, indexOf(end))
111+
.joinToString("\n")
112+
.let(::markdownToHTML)
112113
}
113114
}
114115

115-
val changelog = project.changelog
116-
changeNotes =
117-
providers
118-
.gradleProperty("pluginVersion")
119-
.map { it.substringBefore('-', "") }
120-
.map { pluginVersion ->
121-
with(changelog) {
122-
renderItem(
123-
(getOrNull(pluginVersion) ?: getUnreleased())
124-
.withHeader(false)
125-
.withEmptySections(false),
126-
Changelog.OutputType.HTML,
127-
)
128-
}
129-
}
130-
131116
ideaVersion {
132117
sinceBuild = providers.gradleProperty("pluginSinceBuild")
133118
untilBuild = providers.gradleProperty("pluginUntilBuild")
@@ -141,12 +126,11 @@ intellijPlatform {
141126
}
142127

143128
publishing {
144-
// TODO: During release, refrain from reformatting the version number.
145-
// Instead, set the release version before tagging to allow releases to any chosen channel.
146129
token = providers.environmentVariable("PUBLISH_TOKEN")
147-
version =
148-
providers.gradleProperty("pluginVersion").map { it.substringBefore('-', "") }
149-
channels = listOf("default")
130+
channels =
131+
providers
132+
.gradleProperty("pluginVersion")
133+
.map { listOf(it.substringAfter('-', "").substringBefore('.').ifEmpty { "default" }) }
150134
}
151135

152136
pluginVerification {
@@ -294,7 +278,7 @@ tasks.register("updateChangelog") {
294278
.trim()
295279
}
296280

297-
val tagsOutput = runCommand("git tag --sort=-v:refname")
281+
val tagsOutput = runCommand("git tag --sort=-v:creatordate")
298282
val semverRegex = Regex("^\\d+\\.\\d+\\.\\d+$")
299283
val tags = tagsOutput.lines().filter { semverRegex.matches(it) }
300284
if (tags.isEmpty()) {
@@ -433,6 +417,9 @@ tasks.register("updateChangelog") {
433417
changelogFile.writeText(updatedContent)
434418
changelogFile.appendText("[$newVersion]: $repoUrl/compare/$lastTag...$newVersion\n")
435419

420+
// Update Version Gradle pluginVersion
421+
replaceVersionGradleProperty(newVersion)
422+
436423
val githubEnv = System.getenv("GITHUB_ENV")
437424
val envFile = File(githubEnv)
438425
envFile.appendText("NEW_VERSION=$newVersion\n")

0 commit comments

Comments
 (0)