Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #!/bin/sh
  2. #######################################################################
  3. # version.sh - #
  4. # This script will check for the latest commit badge #
  5. # and will return a version numeber that corresponds #
  6. # to the semver spec. #
  7. # Latest commit tag should have '(patch)', '(minor)' or '(major) #
  8. # in the comment. The script is not case sensitive. #
  9. # Other badges will be interpreted as patch version #
  10. # #
  11. # Written by David Yahalomi - 11/07/2015 #
  12. #######################################################################
  13.  
  14.  
  15. up_major() {
  16. if [[ -z $(git tag -l) ]]; then
  17. echo v1.0.0;
  18. else
  19. git tag -l | tail -1 | awk -F'.' '{$1+=1; print "v"$1".0.0"}'
  20. fi
  21. }
  22.  
  23. up_minor() {
  24. if [[ -z $(git tag -l) ]]; then
  25. echo v0.1.0;
  26. else
  27. git tag -l | tail -1 | awk -F'.' '{$2+=1; print $1"."$2".0"}'
  28. fi
  29. }
  30.  
  31. up_patch() {
  32. if [[ -z $(git tag -l) ]]; then
  33. echo v0.0.1;
  34. else
  35. git tag -l | tail -1 | awk -F'.' '{$3+=1; print $1"."$2"."$3}'
  36. fi
  37. }
  38.  
  39. version=$(git log --pretty="%s" -n1 | sed 's/(\(.*\)).*/\1/' | tr '[:upper:]' '[:lower:]')
  40.  
  41. case $version in
  42. minor ) up_minor
  43. ;;
  44. major ) up_major
  45. ;;
  46. * ) up_patch
  47. ;;
  48. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement