From ef49543c5d31bd1fe39d207f5728f40a7fa67b07 Mon Sep 17 00:00:00 2001 From: Joe Stringer Date: Mon, 19 Jul 2021 17:09:15 -0700 Subject: [PATCH] contrib: Improve release script guard rails [ upstream commit 189cf7f4f73e49618ae8975fc9d297c9a107872b ] * Print help if zero args are provided * Pick up on invalid URLs with a simple regex to avoid failing early * Add the actions URL to the commit and PR messages. Signed-off-by: Joe Stringer Signed-off-by: Paul Chaignon --- contrib/release/post-release.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/contrib/release/post-release.sh b/contrib/release/post-release.sh index 591d3cf251fb7..80ac33d6e8edf 100755 --- a/contrib/release/post-release.sh +++ b/contrib/release/post-release.sh @@ -23,7 +23,7 @@ handle_args() { common::exit 1 fi - if [[ "$1" = "--help" ]] || [[ "$1" = "-h" ]]; then + if [[ "$1" = "--help" ]] || [[ "$1" = "-h" ]] || [[ $# -lt 1 ]]; then usage common::exit 0 fi @@ -39,6 +39,11 @@ handle_args() { exit 1 fi + if ! echo "$1" | grep -q ".*github.com.*actions.*"; then + echo "Invalid URL. The URL must be the overall actions page, not one specific run." 1>&2 + exit 1 + fi + if [ ! -z "$2" ] && ! echo "$2" | grep -q "[0-9]\+\.[0-9]\+\.[0-9]\+"; then usage 2>&1 common::exit 1 "Invalid VERSION ARG \"$2\"; Expected X.Y.Z" @@ -64,7 +69,7 @@ main() { logecho "Check that the following changes look correct:" # TODO: Make this less interactive when we have used it enough git add --patch install/kubernetes - git commit -se -m "install: Update image digests for $version" -m "$(cat digest-$version.txt)" + git commit -se -m "install: Update image digests for $version" -m "Generated from $1." -m "$(cat digest-$version.txt)" echo "Create PR for v$branch with these changes" if ! common::askyorn ; then common::exit 0 "Aborting post-release updates."