Skip to content

Commit 81e98a8

Browse files
committed
Add changelog to github release notes
So we don't have to manually add the release notes to the github release after it is published. I added a custom task to read in the full changelog, and parse out the entry for the latest version. The result is written out to a resources file that I pointed the github release config to. The jreleaser docs don't seem to be 100% clear on whether the changelog is actually what ends up in the release notes, but it would make sense to me, and the text in https://jreleaser.org/guide/latest/reference/release/github.html#_release_notes suggests it.
1 parent cd42c8d commit 81e98a8

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

build.gradle

+24-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
1717
import org.gradle.api.tasks.testing.logging.TestLogEvent
1818

19+
import java.util.regex.Pattern
20+
1921

2022
buildscript {
2123
repositories {
@@ -272,6 +274,27 @@ runtime {
272274
tasks["assembleDist"].dependsOn("publish")
273275
tasks["assembleDist"].dependsOn("runtimeZip")
274276

277+
// Generate a changelog that only includes the changes for the latest version
278+
// which Jreleaser will add to the release notes of the github release.
279+
def releaseChangelogFile = project.layout.buildDirectory.file("resources/RELEASE_CHANGELOG.md").get().asFile
280+
tasks.register("createReleaseChangelog") {
281+
dependsOn processResources
282+
283+
doLast {
284+
def changelog = project.file("CHANGELOG.md").text
285+
// Copy the text in between the first two version headers
286+
def matcher = Pattern.compile("^## \\d+\\.\\d+\\.\\d+", Pattern.MULTILINE).matcher(changelog)
287+
def getIndex = {
288+
matcher.find()
289+
return matcher.start()
290+
}
291+
def result = changelog.substring(getIndex(), getIndex()).trim()
292+
releaseChangelogFile.write(result)
293+
}
294+
}
295+
296+
tasks.jreleaserRelease.dependsOn(tasks.createReleaseChangelog)
297+
275298
jreleaser {
276299
dryrun = false
277300

@@ -290,7 +313,7 @@ jreleaser {
290313
tagName = '{{projectVersion}}'
291314
releaseName = 'Smithy Language Server v{{{projectVersion}}}'
292315
changelog {
293-
enabled = false
316+
external = releaseChangelogFile.absolutePath
294317
}
295318
commitAuthor {
296319
name = "smithy-automation"

0 commit comments

Comments
 (0)