From 35b1cc8b7b50b04367651ff4a4bbcc873ebd967b Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:39:31 +0100 Subject: [PATCH] terminate script when a command fails - Previously, when the git push command failed, the script would still echo a success message. - This commit also makes sure the git describe command does not terminate the script. --- script/release | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index 81242a2..22cc111 100755 --- a/script/release +++ b/script/release @@ -1,5 +1,9 @@ #!/bin/bash +# Exit early +# See: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin +set -e + # About: # # This is a helper script to tag and push a new release. GitHub Actions use @@ -29,9 +33,7 @@ GREEN='\033[0;32m' BLUE='\033[0;34m' # Get the latest release tag -latest_tag=$(git describe --abbrev=0 --match="$tag_glob") - -if [[ -z "$latest_tag" ]]; then +if ! latest_tag=$(git describe --abbrev=0 --match="$tag_glob"); then # There are no existing release tags echo -e "No tags found (yet) - Continue to create and push your first tag" latest_tag="[unknown]"