From e2a6737542e4ee28732583e0fa8e8ff448e4a307 Mon Sep 17 00:00:00 2001 From: Dom Delnano Date: Mon, 16 Dec 2024 10:33:27 -0800 Subject: [PATCH] Fix release note generation script (#2056) Summary: Fix release note generation script Our releases have blank release notes. This makes it difficult for end users to understand what has changed between releases. This PR updates the existing script that was built to auto generate changelog notes. Relevant Issues: N/A Type of change: /kind bug Test Plan: Ran the script for each artifact type and verified the output was expected - [x] cli release notes are expected ``` $ ./scripts/create_release_tag.sh cli -n $ git tag -l --format='%(contents)' release/cli/v0.9.0-pre-ddelnano-fix-release-note-generation.4 ### New Features - (#2048) Enhanced the `px` cli to detect OpenShift clusters and prompt to install the appropriate SecurityContextConstraints before proceeding with a deploy ``` - [x] vizier release notes are expected ``` # Needed to modify prev_tag in script since v0.14.13 to main's HEAD doesn't have vizier changelog messages $ ./scripts/create_release_tag.sh vizier -n $ git tag -l --format='%(contents)' release/vizier/v0.15.0-pre-main.4 ### Bug Fixes - (#2047) Ensures that the `--stirling_bpf_loop_limit` and `--stirling_bpf_chunk_limit` values are respected if explicitly provided on the command line. For 5.1 and later kernels, cli provided values would have been ignored ``` - [x] cloud release notes are generated correctly ``` $ ./scripts/create_release_tag.sh cloud -n Generating changelog from release/cloud/v0.1.8..release/cloud/v0.2.0-pre-ddelnano-fix-release-note-generation.1 $ git tag -l --format='%(contents)' release/cloud/v0.2.0-pre-ddelnano-fix-release-note-generation.1 ### New Features - (#2043) Add support for rendering differential flamegraphs in the `StackTraceFlameGraph` display spec ### Bug Fixes - (#2041) Upgraded bcc and libbpf to support kernels 6.10 and later ``` --- scripts/create_release_tag.sh | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/scripts/create_release_tag.sh b/scripts/create_release_tag.sh index b3a4ff1d85c..93f9f09693c 100755 --- a/scripts/create_release_tag.sh +++ b/scripts/create_release_tag.sh @@ -140,6 +140,12 @@ function generate_changelog { log=$(git log --format=%B -n 1 "$commit") + # PR title line will be suffixed with (#) + 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 @@ -147,27 +153,38 @@ function generate_changelog { 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 @@ -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