Skip to content

Commit

Permalink
Fix release notes generation script
Browse files Browse the repository at this point in the history
Signed-off-by: Dom Del Nano <[email protected]>
  • Loading branch information
ddelnano committed Dec 9, 2024
1 parent 9e54dc8 commit ae54a7e
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions scripts/create_release_tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,34 +140,51 @@ function generate_changelog {

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

# PR title line will be suffixed with (#<PR number>)
prTitle=$(echo $log | head -n1)
if [[ $prTitle =~ \(\#([0-9]+)\) ]]; then
prNum=${BASH_REMATCH[1]}
fi

# Get the type of change (cleanup|bug|feature).
typeRe='Type of change: /kind ([A-Za-z]+)'
if [[ $log =~ $typeRe ]]; then
changeType=${BASH_REMATCH[1]}
fi

# Get release notes.
notesRe="\`\`\`release-note\s*(.*)\`\`\`"
if [[ $log =~ $notesRe ]]; then
releaseNote=${BASH_REMATCH[1]}
fi
releaseNote=$(echo "$log" | awk '
BEGIN { output = ""; capturing = 0 }
/Changelog Message:/ { capturing = 1 }
/---------/ { capturing = 0 }
/Signed-off-by/ { capturing = 0 }
capturing {
print $0
}
' | sed 's/Changelog Message: //')

declare -a cleanup_changelog
declare -a bug_changelog
declare -a feature_changelog

if [[ -n $releaseNote ]]; then
fullReleaseNote="(#$prNum) $releaseNote"
case $changeType in
"cleanup")
cleanup_changelog+=("$releaseNote")
cleanup_changelog+=("$fullReleaseNote")
;;
"bug")
bug_changelog+=("$releaseNote")
bug_changelog+=("$fullReleaseNote")
;;
"bugfix")
bug_changelog+=("$fullReleaseNote")
;;
"feature")
feature_changelog+=("$releaseNote")
feature_changelog+=("$fullReleaseNote")
;;
*)
# If the type change is wrong, fail so that invalid entries can be fixed
exit 1
;;
esac
fi
Expand Down Expand Up @@ -248,6 +265,7 @@ if [ "$RELEASE" != "true" ]; then
new_version_str=$(update_pre "$new_version_str" "$commit_count" "$sanitized_branch")
fi

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

new_tag="release/$ARTIFACT_TYPE/v"$new_version_str
Expand Down

0 comments on commit ae54a7e

Please sign in to comment.