Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #######################################################################
- # version.sh - #
- # This script will check for the latest commit badge #
- # and will return a version numeber that corresponds #
- # to the semver spec. #
- # Latest commit tag should have '(patch)', '(minor)' or '(major) #
- # in the comment. The script is not case sensitive. #
- # Other badges will be interpreted as patch version #
- # #
- # Written by David Yahalomi - 11/07/2015 #
- #######################################################################
- up_major() {
- if [[ -z $(git tag -l) ]]; then
- echo v1.0.0;
- else
- git tag -l | tail -1 | awk -F'.' '{$1+=1; print "v"$1".0.0"}'
- fi
- }
- up_minor() {
- if [[ -z $(git tag -l) ]]; then
- echo v0.1.0;
- else
- git tag -l | tail -1 | awk -F'.' '{$2+=1; print $1"."$2".0"}'
- fi
- }
- up_patch() {
- if [[ -z $(git tag -l) ]]; then
- echo v0.0.1;
- else
- git tag -l | tail -1 | awk -F'.' '{$3+=1; print $1"."$2"."$3}'
- fi
- }
- version=$(git log --pretty="%s" -n1 | sed 's/(\(.*\)).*/\1/' | tr '[:upper:]' '[:lower:]')
- case $version in
- minor ) up_minor
- ;;
- major ) up_major
- ;;
- * ) up_patch
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement