From b311c1b665eaa4618c6fbd96ec9340a6d0e8a607 Mon Sep 17 00:00:00 2001 From: Andriy Dzikh Date: Thu, 15 Jul 2021 13:14:13 -0700 Subject: [PATCH] Replace gh_token.txt with gh auth parsing in release notes. --- hack/release_notes.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hack/release_notes.sh b/hack/release_notes.sh index 164685ab2d..444e9eedb4 100755 --- a/hack/release_notes.sh +++ b/hack/release_notes.sh @@ -18,10 +18,15 @@ set -eu -o pipefail DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -if ! [[ -r "${DIR}/gh_token.txt" ]]; then - echo "Missing '${DIR}/gh_token.txt'. Please create a GitHub token at https://github.com/settings/tokens and store in '${DIR}/gh_token.txt'." - exit 1 -fi +# Parse the token from `gh auth` +TMP_TOKEN=$(mktemp) +gh auth status -t 2>&1 | sed -n -r 's/^.*Token: ([a-zA-Z0-9_]*)/\1/p' > "$TMP_TOKEN" + +# Ensure the token is deleted when the script exits, so the token is not leaked. +function cleanup_token() { + rm -f "$TMP_TOKEN" +} +trap cleanup_token EXIT install_release_notes_helper() { release_notes_workdir="$(mktemp -d)" @@ -58,12 +63,12 @@ echo "Thank you to our PR reviewers for this release!" echo "" AWK_FORMAT_ITEM='{printf "- %s (%d comments)\n", $2, $1}' AWK_REVIEW_COMMENTS='NR>1{arr[$4] += $6 + $7}END{for (a in arr) printf "%d %s\n", arr[a], a}' -"${DIR}/pullsheet" reviews --since "$recent_date" --repos kubernetes/minikube --token-path $DIR/gh_token.txt --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_REVIEW_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" +"${DIR}/pullsheet" reviews --since "$recent_date" --repos kubernetes/minikube --token-path "$TMP_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_REVIEW_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" echo "" echo "Thank you to our triage members for this release!" echo "" AWK_ISSUE_COMMENTS='NR>1{arr[$4] += $7}END{for (a in arr) printf "%d %s\n", arr[a], a}' -"${DIR}/pullsheet" issue-comments --since "$recent_date" --repos kubernetes/minikube --token-path $DIR/gh_token.txt --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_ISSUE_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" | head -n 5 +"${DIR}/pullsheet" issue-comments --since "$recent_date" --repos kubernetes/minikube --token-path "$TMP_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_ISSUE_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" | head -n 5 if [[ "$recent" != *"beta"* ]]; then echo ""