Skip to content

Commit

Permalink
contrib: Improve release script guard rails
Browse files Browse the repository at this point in the history
[ upstream commit 189cf7f ]

* 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 <joe@cilium.io>
Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
joestringer authored and pchaigno committed Jul 29, 2021
1 parent 960e3de commit ef49543
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions contrib/release/post-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand All @@ -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."
Expand Down

0 comments on commit ef49543

Please sign in to comment.