Skip to content

Commit 4de5a99

Browse files
author
Stewart Miles
committed
Embed release notes and download link in release tags.
Bug: 132188969 Change-Id: Ic21075f8c06a1157b7e5491858fceac9e1b4fe1a
1 parent 4bdc8d8 commit 4de5a99

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

build.gradle

+34-11
Original file line numberDiff line numberDiff line change
@@ -1196,16 +1196,36 @@ task gitAddReleaseFilesToStaging(type: Exec, dependsOn: releasePlugin) {
11961196
commandLine "git", "add", "-A"
11971197
}
11981198

1199+
/*
1200+
* Read the changes applied to the current version from the changelog.
1201+
*
1202+
* @returns Version summary in a multiline string.
1203+
*/
1204+
String readVersionSummaryFromChangelog() {
1205+
String versionSummary = ""
1206+
for (String line in project.ext.changelog.text.split("\n")) {
1207+
String trimmedLine = line.trim()
1208+
if (line.isEmpty()) break
1209+
versionSummary += line + "\n"
1210+
}
1211+
return versionSummary
1212+
}
1213+
1214+
/*
1215+
* Create a commit message for a release commit.
1216+
*
1217+
* @returns Commit message string.
1218+
*/
1219+
String createCommitMessage() {
1220+
return sprintf("Version %s\n\n%s",
1221+
project.ext.pluginVersionSemVer,
1222+
readVersionSummaryFromChangelog())
1223+
}
1224+
11991225
task gitCreateReleaseCommit(dependsOn: gitAddReleaseFilesToStaging) {
12001226
description "Run git to create a release commit."
12011227

12021228
doLast {
1203-
String versionSummary = ""
1204-
for (String line in project.ext.changelog.text.split("\n")) {
1205-
String trimmedLine = line.trim()
1206-
if (line.isEmpty()) break
1207-
versionSummary += line + "\n"
1208-
}
12091229
def stdout = new ByteArrayOutputStream()
12101230
exec {
12111231
commandLine "git", "status", "-s"
@@ -1214,10 +1234,7 @@ task gitCreateReleaseCommit(dependsOn: gitAddReleaseFilesToStaging) {
12141234
}
12151235
if (!stdout.toString().isEmpty()) {
12161236
exec {
1217-
commandLine "git", "commit", "-a", "-m",
1218-
sprintf("Version %s\n\n%s",
1219-
project.ext.pluginVersionSemVer,
1220-
versionSummary)
1237+
commandLine "git", "commit", "-a", "-m", createCommitMessage()
12211238
}
12221239
}
12231240
}
@@ -1228,7 +1245,13 @@ task gitTagRelease(type: Exec, dependsOn: gitCreateReleaseCommit) {
12281245
"*after* a release commit has been be created.")
12291246
commandLine "git", "tag", "-a",
12301247
sprintf("v%s", pluginVersionSemVer), "-m",
1231-
sprintf("release %s", pluginVersionSemVer)
1248+
sprintf("%s\n\nDownload [here](%s)",
1249+
createCommitMessage(),
1250+
sprintf("https://github.com/googlesamples/" +
1251+
"unity-jar-resolver/raw/v%s/" +
1252+
"play-services-resolver-%s.unitypackage",
1253+
project.ext.pluginVersionSemVer,
1254+
project.ext.pluginVersion))
12321255
}
12331256

12341257
// TODO: Version Handler tests to implement in both batch and interactive modes

0 commit comments

Comments
 (0)