Git semantic versioning, only simpler

A while ago I’ve written an article about Git and semantic versioning. All is cool and nice, but what if you don’t need that much complex stuff and just need a simple, minor version increase ?

Well, you can do like this:

// Default tag, in case a new version was not found
export CURRENT_VERSION=$((git describe --tags --abbrev=0 2>/dev/null) || echo '1.0.0')
export CURRENT_VERSION=${CURRENT_VERSION:'1.0.0'}
export MAJOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f1)
export MINOR_VERSION=$(echo $CURRENT_VERSION | cut -d. -f2)
export PATCH_VERSION=$(echo $CURRENT_VERSION | cut -d. -f3)
export MINOR_VERSION=$((MINOR_VERSION + 1))
export TAG="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}"
echo "Releasing $TAG"
git tag -a "$TAG" -m "Tagging $TAG"
git push origin $TAG

Simple and works.

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *