Skip to content

Instantly share code, notes, and snippets.

@SevereCloud
Last active May 24, 2020 12:20
Show Gist options
  • Save SevereCloud/c6a08b6b3998b449e5b7bc935fea1feb to your computer and use it in GitHub Desktop.
Save SevereCloud/c6a08b6b3998b449e5b7bc935fea1feb to your computer and use it in GitHub Desktop.
Updating version
#!/bin/bash
#get highest tag number
VERSION=`git describe --abbrev=0 --tags`
#replace . with space so can split into an array
VERSION_BITS=(${VERSION//./ })
#get number parts and increase last one by 1
VNUM1=${VERSION_BITS[0]}
VNUM2=${VERSION_BITS[1]}
VNUM3=${VERSION_BITS[2]}
if git --no-pager log $VERSION... --pretty=format:'%s' | grep -q '^feat'; then
VNUM2=$((VNUM2+1))
VNUM3=0
elif git --no-pager log $VERSION... --pretty=format:'%s' | grep -q '^fix'; then
VNUM3=$((VNUM3+1))
fi
#create new tag
NEW_TAG="$VNUM1.$VNUM2.$VNUM3"
if [ "$VERSION" == "$NEW_TAG" ]; then
echo "No updates"
else
echo "Updating $VERSION to $NEW_TAG"
# git tag -a $NEW_TAG
echo ""
echo "### Changelog"
echo ""
git log $VERSION... --pretty=format:'%h %s' --reverse | grep -v -E '^[[:alnum:]]{7} chore|docs|style|refactor|perf|test|docs|Merge'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment