From 6348ea95158b24b873eb44d6c02eb617eb30f377 Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Mon, 28 Mar 2022 17:54:09 -0400 Subject: [PATCH] Improve logging for changelong builder --- releasing/README.md | 32 ++++++++++++++++++++++++++++---- releasing/compile-changelog.sh | 19 +++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/releasing/README.md b/releasing/README.md index bcd9f51e18..e08a89ee4b 100644 --- a/releasing/README.md +++ b/releasing/README.md @@ -118,7 +118,13 @@ refreshMaster && testKustomizeRepo ``` -While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. +While you're waiting for the tests, review the commit log: + +``` +releasing/compile-changelog.sh kyaml HEAD +``` + +Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. kyaml has no intra-repo deps, so if the tests pass, it can just be released. @@ -185,7 +191,13 @@ refreshMaster && testKustomizeRepo ``` -While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. +While you're waiting for the tests, review the commit log: + +``` +releasing/compile-changelog.sh cmd/config HEAD +``` + +Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. #### Release it @@ -243,7 +255,13 @@ refreshMaster && testKustomizeRepo ``` -While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. +While you're waiting for the tests, review the commit log: + +``` +releasing/compile-changelog.sh api HEAD +``` + +Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. #### Release it @@ -298,7 +316,13 @@ refreshMaster && testKustomizeRepo ``` -While you're waiting for the tests, review the commit log. Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. +While you're waiting for the tests, review the commit log: + +``` +releasing/compile-changelog.sh kustomize HEAD +``` + +Based on the changes to be included in this release, decide whether a patch, minor or major version bump is needed: [semver review]. #### Release it diff --git a/releasing/compile-changelog.sh b/releasing/compile-changelog.sh index e79b926968..f516dc60ab 100755 --- a/releasing/compile-changelog.sh +++ b/releasing/compile-changelog.sh @@ -18,7 +18,7 @@ set -o errexit set -o nounset set -o pipefail -if [[ -z "${1-}" ]] || [[ -z "${2-}" ]] || [[ -z "${3-}" ]]; then +if [[ -z "${1-}" ]] || [[ -z "${2-}" ]]; then echo "Usage: $0 " echo "Example: $0 kyaml kyaml/v0.13.4 changelog.txt" exit 1 @@ -26,16 +26,19 @@ fi module=$1 fullTag=$2 -changeLogFile=$3 +changeLogFile="${3:-}" # Find previous tag that matches the tags module prevTag=$(git tag -l "$module*" --sort=-version:refname --no-contains="$fullTag" | head -n 1) +echo "Compiling $module changes from $prevTag to $fullTag" commits=( $(git log "$prevTag".."$fullTag" \ --pretty=format:'%H' \ --abbrev-commit --no-decorate --no-color --no-merges \ -- "$module") ) +echo "Gathering PRs for commits: ${commits[*]}" + # There is a 256 character limit on the query parameter for the GitHub API, so split into batches then deduplicate results batchSize=5 results="" @@ -45,9 +48,17 @@ do if newResults=$(curl -sSL "https://api.github.com/search/issues?q=$commitList+repo%3Akubernetes-sigs%2Fkustomize" | jq -r '[ .items[] | { number, title } ]'); then results=$(echo "$results" "$newResults" | jq -s '.[0] + .[1] | unique') else - echo "Failed to fetch results for commits: $commitList" + echo "Failed to fetch results for commits (exit code $?): $commitList" exit 1 fi done -echo "${results}" | jq -r '.[] | select( .title | startswith("Back to development mode") | not) | "#\(.number): \(.title)" ' > "$changeLogFile" +changelog=$(echo "${results}" | jq -r '.[] | select( .title | startswith("Back to development mode") | not) | "#\(.number): \(.title)" ') + +if [[ -n "$changeLogFile" ]]; then + echo "$changelog" > "$changeLogFile" +else + echo + echo "----CHANGE LOG----" + echo "$changelog" +fi