Created
July 14, 2016 01:23
-
-
Save mcgwiz/b5c9e9a585db2dd5a24bfc10220009df to your computer and use it in GitHub Desktop.
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
OWNER=$(echo ${TRAVIS_REPO_SLUG} | grep -Po '\w*' | head -n 1) | |
# Get the tags | |
TAGS="$(curl -s -u ${OWNER}:${SECRET} https://api.github.com/repos/${TRAVIS_REPO_SLUG}/git/refs/tags | grep -Po '(ref|sha)":.*' | paste -d" " - -)" | |
# Get the most recent tag number | |
VER=$(echo "${TAGS}" | sed 's/ref": "refs\/tags\/v//g' | sed 's/", sha":.*//g' | sort -V | tail -n 1) | |
# Get the associated tag ref | |
TAG_SHA=$(echo "${TAGS}" | grep $VER | sed 's/.*sha": "//g' | sed 's/",//g') | |
# Get the associated commit ref | |
COM_SHA=$(curl -s -u ${OWNER}:${SECRET} https://api.github.com/repos/${TRAVIS_REPO_SLUG}/git/tags/${SHA} | grep sha | tail -n 1 | grep -Po \\w{40}) | |
# Get the commits-after count | |
POINT_VER=$(curl -s -u ${OWNER}:${SECRET} https://api.github.com/repos/${TRAVIS_REPO_SLUG}/compare/${COM_REF}...${TRAVIS_COMMIT} | grep ahead_by | grep -Po '\d*') | |
FINAL_VER="${VER}.${POINT_VER}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment