Skip to content

Commit

Permalink
Update changelog plugin
Browse files Browse the repository at this point in the history
The new version provides the following improvements:

* The workaround for missing line feeds at the end of the CHANGELOG.md
  is no-longer necessary (fixed upstream)
* The plugin automatically strips empty sections
* The plugin allows to add a summery to releases
* The header of future releases will also contains a date
  • Loading branch information
JojOatXGME committed Jun 27, 2023
1 parent 50dca65 commit 73d909e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 21 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.changelog.Changelog
import org.jetbrains.changelog.markdownToHTML
import org.jetbrains.grammarkit.tasks.GenerateLexerTask
import org.jetbrains.grammarkit.tasks.GenerateParserTask
Expand All @@ -8,7 +9,7 @@ plugins {
// gradle-intellij-plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
id("org.jetbrains.intellij") version "1.13.3"
// gradle-changelog-plugin - read more: https://github.com/JetBrains/gradle-changelog-plugin
id("org.jetbrains.changelog") version "1.3.1"
id("org.jetbrains.changelog") version "2.0.0"
// grammarkit - read more: https://github.com/JetBrains/gradle-grammar-kit-plugin
id("org.jetbrains.grammarkit") version "2021.2.2"
}
Expand Down Expand Up @@ -52,7 +53,10 @@ intellij {
}

changelog {
lineSeparator.set("\n")
// Workarounds because our version numbers do not match the format of semantic versioning:
headerParserRegex.set("^[-._+0-9a-zA-Z]+\$")
combinePreReleases.set(false)
}

grammarKit {
Expand Down Expand Up @@ -129,7 +133,14 @@ tasks {
dir.mkdirs()
dir.resolve("version.txt").writeText(pluginVersion)
dir.resolve("zipfile.txt").writeText(buildPlugin.get().archiveFile.get().toString())
dir.resolve("latest_changelog.md").writeText(changelog.getLatest().toText())
dir.resolve("latest_changelog.md").writeText(with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.MARKDOWN
)
})
}
}

Expand Down Expand Up @@ -175,7 +186,14 @@ tasks {
)

// Get the latest available change notes from the changelog file
changeNotes.set(provider { changelog.getLatest().toHTML() })
changeNotes.set(provider { with(changelog) {
renderItem(
(getOrNull(pluginVersion) ?: getUnreleased())
.withHeader(false)
.withEmptySections(false),
Changelog.OutputType.HTML
)
}})
}

runPluginVerifier {
Expand Down
8 changes: 0 additions & 8 deletions gradle/bumpVersion.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ tasks.named("patchChangelog") {
setProperty("releaseNote", releaseNote.replace("\r\n", "\n"))
}
}
// The task (as of org.jetbrains.changelog 1.3.1) removes trailing newlines from the changelog.
// Add a trailing newline afterwards as a workaround.
doLast {
val file = file(property("outputFile"))
if (!file.readText().endsWith("\n")) {
file.appendText("\n")
}
}
}

/**
Expand Down

0 comments on commit 73d909e

Please sign in to comment.