Skip to content

Commit 6970b55

Browse files
committed
Fix release notes generation script
Signed-off-by: Dom Del Nano <ddelnano@gmail.com> (cherry picked from commit ae54a7e)
1 parent 672e351 commit 6970b55

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

scripts/create_release_tag.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,34 +140,51 @@ function generate_changelog {
140140

141141
log=$(git log --format=%B -n 1 "$commit")
142142

143+
# PR title line will be suffixed with (#<PR number>)
144+
prTitle=$(echo $log | head -n1)
145+
if [[ $prTitle =~ \(\#([0-9]+)\) ]]; then
146+
prNum=${BASH_REMATCH[1]}
147+
fi
148+
143149
# Get the type of change (cleanup|bug|feature).
144150
typeRe='Type of change: /kind ([A-Za-z]+)'
145151
if [[ $log =~ $typeRe ]]; then
146152
changeType=${BASH_REMATCH[1]}
147153
fi
148154

149155
# Get release notes.
150-
notesRe="\`\`\`release-note\s*(.*)\`\`\`"
151-
if [[ $log =~ $notesRe ]]; then
152-
releaseNote=${BASH_REMATCH[1]}
153-
fi
156+
releaseNote=$(echo "$log" | awk '
157+
BEGIN { output = ""; capturing = 0 }
158+
/Changelog Message:/ { capturing = 1 }
159+
/---------/ { capturing = 0 }
160+
/Signed-off-by/ { capturing = 0 }
161+
capturing {
162+
print $0
163+
}
164+
' | sed 's/Changelog Message: //')
154165

155166
declare -a cleanup_changelog
156167
declare -a bug_changelog
157168
declare -a feature_changelog
158169

159170
if [[ -n $releaseNote ]]; then
171+
fullReleaseNote="(#$prNum) $releaseNote"
160172
case $changeType in
161173
"cleanup")
162-
cleanup_changelog+=("$releaseNote")
174+
cleanup_changelog+=("$fullReleaseNote")
163175
;;
164176
"bug")
165-
bug_changelog+=("$releaseNote")
177+
bug_changelog+=("$fullReleaseNote")
178+
;;
179+
"bugfix")
180+
bug_changelog+=("$fullReleaseNote")
166181
;;
167182
"feature")
168-
feature_changelog+=("$releaseNote")
183+
feature_changelog+=("$fullReleaseNote")
169184
;;
170185
*)
186+
# If the type change is wrong, fail so that invalid entries can be fixed
187+
exit 1
171188
;;
172189
esac
173190
fi
@@ -248,6 +265,7 @@ if [ "$RELEASE" != "true" ]; then
248265
new_version_str=$(update_pre "$new_version_str" "$commit_count" "$sanitized_branch")
249266
fi
250267

268+
echo "Generating changelog from ${prev_tag}..release/${ARTIFACT_TYPE}/v${new_version_str}"
251269
changelog=$(generate_changelog "$prev_tag" "$BAZEL_TARGET")
252270

253271
new_tag="release/$ARTIFACT_TYPE/v"$new_version_str

0 commit comments

Comments
 (0)