Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env bash
##
# check out latest semvar tag from git master repo
##
## exit if script fails
set -e
## get current branch checked out
CURRENT=`git rev-parse --abbrev-ref HEAD`
## check if current branch is master
if [ "$CURRENT" = "master" ]; then
## debug
git tag | sed -e 's/[^0-9\.]//g' | sort -V
## get latest tag from master
##TAG=`git tag | sort -V | tail -n1`
TAG=$(git tag | sed -e 's/[^0-9\.]//g' | sort -V | tail -n1)
## log latest tag from master
echo "latest tag: $TAG"
echo "########## LATEST TAG FROM BRANCH ##########"
git describe --always --abbrev=0
echo "########## END LATEST TAG FROM BRANCH ##########"
echo "########## CURRENTLY CHECKED OUT ##########"
git rev-parse --abbrev-ref HEAD
echo "########## END CURRENTLY CHECKED OUT ##########"
echo "########## CHECKING OUT LATEST TAG ##########"
git checkout $TAG
echo "########## END CHECKING OUT LATEST TAG ##########"
echo "########## NOW CHECKED OUT ##########"
git describe --always --abbrev=0
echo "########## END NOW CHECKED OUT ##########"
else
echo “none production build”
## get branch name from git
branch=$(git rev-parse --abbrev-ref HEAD)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.