Skip to content

Commit b05f60c

Browse files
committed
Add small task to verify changelog is correct
Also use the changelog contents as the GH release notes
1 parent c44c560 commit b05f60c

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

build.gradle

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,46 @@ task compressJson(dependsOn: extractAnnotationsJar) {
226226

227227
assemble.dependsOn compressJson
228228

229+
task checkRelease(dependsOn: extractAnnotationsJar) {
230+
group "upload"
231+
description "Verifies that everything is ready for a release"
232+
233+
inputs.property "version", mod_version
234+
inputs.file("src/main/resources/assets/computercraft/lua/rom/help/changelog.txt")
235+
inputs.file("src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt")
236+
237+
doLast {
238+
def ok = true
239+
240+
// Check we're targetting the current version
241+
def whatsnew = new File("src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt").readLines()
242+
if (whatsnew[0] != "New features in CC: Tweaked $mod_version") {
243+
ok = false
244+
project.logger.error("Expected `whatsnew.txt' to target $mod_version.")
245+
}
246+
247+
// Check "read more" exists and trim it
248+
def idx = whatsnew.findIndexOf { it == 'Type "help changelog" to see the full version history.' }
249+
if (idx == -1) {
250+
ok = false
251+
project.logger.error("Must mention the changelog in whatsnew.txt")
252+
} else {
253+
whatsnew = whatsnew.getAt(0 ..< idx)
254+
}
255+
256+
// Check whatsnew and changelog match.
257+
def versionChangelog = "# " + whatsnew.join("\n")
258+
def changelog = new File("src/main/resources/assets/computercraft/lua/rom/help/changelog.txt").getText()
259+
if (!changelog.startsWith(versionChangelog)) {
260+
ok = false
261+
project.logger.error("whatsnew and changelog are not in sync")
262+
}
263+
264+
if (!ok) throw new IllegalStateException("Could not check release")
265+
}
266+
}
267+
268+
229269
curseforge {
230270
apiKey = project.hasProperty('curseForgeApiKey') ? project.curseForgeApiKey : ''
231271
project {
@@ -296,17 +336,23 @@ githubRelease {
296336
token project.hasProperty('githubApiKey') ? project.githubApiKey : ''
297337
owner 'SquidDev-CC'
298338
repo 'CC-Tweaked'
299-
targetCommitish (mc_version == "1.12.2" ? "master" : mc_version)
339+
targetCommitish { Grgit.open(dir: '.').branch.current() }
300340

301341
tagName "v${mc_version}-${mod_version}"
302342
releaseName "[${mc_version}] ${mod_version}"
303-
body ''
343+
body {
344+
"##" + new File("src/main/resources/assets/computercraft/lua/rom/help/whatsnew.txt")
345+
.readLines()
346+
.takeWhile { it != 'Type "help changelog" to see the full version history.' }
347+
.join("\n").trim()
348+
}
304349
prerelease false
305350
}
306351

307352
task uploadAll(dependsOn: [uploadArchives, "curseforge", "githubRelease"]) {
308353
group "upload"
309354
description "Uploads to all repositories (Maven, Curse, GitHub release)"
355+
dependsOn checkRelease
310356
}
311357

312358
test {

0 commit comments

Comments
 (0)