-
-
Save aradhell/67316c6314d3cacd338124f58059f777 to your computer and use it in GitHub Desktop.
Automated semantic versioning for travis-ci or any other ci
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export SEMVER_LAST_TAG=$(git describe --tags `git rev-list --tags --max-count=1` 2>/dev/null) | |
export SEMVER_RELEASE_LEVEL=$(git log --oneline -1 --pretty=%B | cat | tr -d '\n' | cut -d "[" -f2 | cut -d "]" -f1) | |
#curl -o /tmp/hub.tgz https://github.com/github/hub/releases/download/v2.2.9/hub-linux-arm64-2.2.9.tgz | |
#tar -xvzf /tmp/hub.tgz -C /tmp | |
if [ -z $SEMVER_LAST_TAG ]; then | |
>&2 echo "No tags defined" | |
SEMVER_LAST_TAG="0.0.1" | |
fi | |
if [ -n $SEMVER_RELEASE_LEVEL ]; then | |
git clone https://github.com/fsaintjacques/semver-tool /tmp/semver &> /dev/null | |
SEMVER_NEW_TAG=$(/tmp/semver/src/semver bump $SEMVER_RELEASE_LEVEL $SEMVER_LAST_TAG) | |
git tag $SEMVER_NEW_TAG &> /dev/null | |
git push origin --tags &> /dev/null | |
echo $SEMVER_NEW_TAG | |
else | |
>&2 echo "No release level defined" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am using https://github.com/fsaintjacques/semver-tool to auto version my builds:
examples:
for patch level
$ git commit -m "[patch] few changes"
for minor patches
$ git commit -m "[minor] added the foo feature"
for major patches
$ git commit -m "[major] added breaking change"