From b8b3accc4b7d08a7ffc2585fa95a712714701a97 Mon Sep 17 00:00:00 2001 From: Haowei Cai Date: Sun, 24 Oct 2021 20:23:50 -0700 Subject: [PATCH] Collect release notes from master branch --- scripts/release.sh | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 285b25440..08251e8d5 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -128,11 +128,6 @@ declare -r newbranchuniq echo "+++ Creating local branch ${newbranchuniq}" git checkout -b "${newbranchuniq}" "${remote_branch}" -# If it's an actual release, pull master branch -if [[ $CLIENT_VERSION != *"snapshot"* ]]; then - git pull -X theirs upstream master -fi - # Get Kubernetes API versions old_client_version=$(python3 "scripts/constants.py" CLIENT_VERSION) old_k8s_api_version=$(util::changelog::get_k8s_api_version "v$old_client_version") @@ -140,6 +135,34 @@ new_k8s_api_version=$(util::kube_changelog::find_latest_patch_version $KUBERNETE echo "Old Kubernetes API Version: $old_k8s_api_version" echo "New Kubernetes API Version: $new_k8s_api_version" +# If it's an actual release, pull master branch +if [[ $CLIENT_VERSION != *"snapshot"* ]]; then + git pull -X theirs upstream master + + # Collect release notes from master branch + start_sha=$(git log upstream/release-19.0..upstream/master | grep ^commit | tail -n1 | sed 's/commit //g') + end_sha=$(git log upstream/release-19.0..upstream/master | grep ^commit | head -n1 | sed 's/commit //g') + output="/tmp/python-master-relnote.md" + release-notes --dependencies=false --org kubernetes-client --repo python --start-sha $start_sha --end-sha $end_sha --output $output + sed -i 's/(\[\#/(\[kubernetes-client\/python\#/g' $output + + IFS_backup=$IFS + IFS=$'\n' + sections=($(grep "^### " $output)) + IFS=$IFS_backup + for section in "${sections[@]}"; do + # ignore section titles and empty lines; replace newline with liternal "\n" + master_release_notes=$(sed -n "/$section/,/###/{/###/!p}" $output | sed -n "{/^$/!p}" | sed ':a;N;$!ba;s/\n/\\n/g') + util::changelog::write_changelog v$CLIENT_VERSION "$section" "$master_release_notes" + done + git add . + if ! git diff-index --quiet --cached HEAD; then + util::changelog::update_release_api_version $CLIENT_VERSION $CLIENT_VERSION $new_k8s_api_version + git add . + git commit -m "update changelog with release notes from master branch" + fi +fi + # Update version constants sed -i "s/^KUBERNETES_BRANCH =.*$/KUBERNETES_BRANCH = \"$KUBERNETES_BRANCH\"/g" scripts/constants.py sed -i "s/^CLIENT_VERSION =.*$/CLIENT_VERSION = \"$CLIENT_VERSION\"/g" scripts/constants.py