Skip to content

Commit f669eb1

Browse files
committed
chore(build): add tasks to allow printing changelog info (for ci)
1 parent 92dc86e commit f669eb1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

build-logic/src/main/groovy/buildlogic.changelog-conventions.gradle

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,28 @@ tasks.register('changelogPrintCurrentVersion') {
2727
println "${versionToPrint}"
2828
}
2929
}
30+
31+
tasks.register('changelogPrintUnreleasedVersionContent') {
32+
def changelog = spotlessChangelog.parsedChangelog
33+
doLast {
34+
println "${changelog.unreleasedChanges()}"
35+
}
36+
}
37+
38+
tasks.register('changelogPrintVersionContent') {
39+
def changelog = spotlessChangelog.parsedChangelog
40+
if (!project.hasProperty('changelogPrintVersion') || project.changelogPrintVersion == '') {
41+
throw new IllegalArgumentException("Please provide a version to print with -PchangelogPrintVersion=<version>")
42+
}
43+
def versionToPrint = project.changelogPrintVersion
44+
doLast {
45+
String changelogString = changelog.toStringUnix()
46+
String changeLog = changelogString.lines()
47+
.dropWhile { String line -> !line.startsWith("## [${versionToPrint}]") }
48+
.skip(1) // skip the version line
49+
.takeWhile { String line -> !line.startsWith("## [") }
50+
.toList()
51+
.join("\n")
52+
println "${changeLog}"
53+
}
54+
}

0 commit comments

Comments
 (0)