#!/bin/bash
set -e

# Create a new tag if the version file has been updated and a tag for that
# version doesn't already exist.

# Are we on master branch?
# We shouldn't push tags for version bump branches.
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "$BRANCH" == "master" ]]; then
  # get the version from the version file
  VERSION_TAG="v`cat VERSION.txt`"

  # check to make sure the tag doesn't already exist
  if ! git rev-parse $VERSION_TAG >/dev/null 2>&1; then
    echo "Creating new tag: $VERSION_TAG"
    git tag $VERSION_TAG
    git push origin $VERSION_TAG
  fi
else
  echo "Not creating release tag because we're on a branch..."
fi

#!/bin/bash
set -ev

# Create a new tag if the version file has been updated and a tag for that
# version doesn't already exist.

# Are we on master branch?
# We shouldn't push tags for version bump branches.
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "$BRANCH" == "master" ]]; then
  # get the version from the version file
  VERSION_TAG="v`cat VERSION.txt`"

  # check to make sure the tag doesn't already exist
  if ! git rev-parse $VERSION_TAG >/dev/null 2>&1; then
    echo "Creating new tag: $VERSION_TAG"
    git tag $VERSION_TAG
    git push origin $VERSION_TAG
  fi
else
  echo "Not creating release tag because we're on a branch..."
fi

Print all lines in the script before executing them
Print all lines in the script before executing them

he -e flag causes the script to exit as soon as one command returns a
non-zero exit code. This can be handy if you want whatever script you
have to exit early. It also helps in complex installation scripts where
one failed command wouldn’t otherwise cause the installation to fail.

The -v flag makes the shell print all lines in the script before
executing them, which helps identify which steps failed.
