Skip to content

Instantly share code, notes, and snippets.

@chbatey
Created February 28, 2022 09:32
Show Gist options
  • Save chbatey/3a8db660d0735af81292aac582f593a7 to your computer and use it in GitHub Desktop.
Save chbatey/3a8db660d0735af81292aac582f593a7 to your computer and use it in GitHub Desktop.
echo "Checking if the commit is already tagged"
if ! git describe --tag --exact-match 2>&1 | grep "fatal";
then
echo "Commit is already tagged"
exit 0
fi
echo "Getting previous tag"
CURRENT_TAG=$$(git describe --tag --abbrev=0)
if [ "$${CURRENT_TAG}" = "" ]
then
echo "Can't find any tags"
NEW_TAG="v1.0.0"
else
echo "Increment minor version"
NEW_TAG=$$(echo "$${CURRENT_TAG}" | awk -F'[v.]' '{print "v"$$2"."$$3+1"."$$4}')
fi
echo "Current tag is $${CURRENT_TAG}"
echo "New tag is $${NEW_TAG}"
echo "Pushing new tag"
git tag "$${NEW_TAG}"
git push origin "$${NEW_TAG}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment