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.
This commit is contained in:
Paul Ebose 2024-07-01 02:39:31 +01:00
parent be270a6def
commit 35b1cc8b7b
No known key found for this signature in database
GPG Key ID: 2FF647AADFAC0FE8

View File

@ -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]"