diff --git a/incrementVersion.sh b/incrementVersion.sh new file mode 100644 index 00000000..0f162e1b --- /dev/null +++ b/incrementVersion.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Constants +TAGS=$(git tag -l --sort="version:refname") +INDEX=${#TAGS} +let "INDEX--" +VERSION=0 +MAJOR=0 +MINOR=0 +PATCH=0 + +# Functions +function findNextPeriod() { + while [[ ${VERSION:$INDEX:1} != "." ]] + do + let "INDEX++" + done +} + +# Find the highest version tag +while [[ ${TAGS:$INDEX:1} != "v" ]] +do + let "INDEX--" +done +VERSION=${TAGS:$INDEX+1} + +# Find the Major number +INDEX=0 +findNextPeriod +MAJOR=${VERSION:0:$INDEX} + +# Find the Minor number +VERSION=${VERSION:$INDEX+1} +findNextPeriod +MINOR=${VERSION:0:$INDEX} + +# Find the Patch number and increment +VERSION=${VERSION:$INDEX+1} +PATCH=$VERSION +let "PATCH++" + +# Return the incremented version +VERSION=v$MAJOR.$MINOR.$PATCH +echo $VERSION diff --git a/wercker.yml b/wercker.yml index b6946b44..b139e5f9 100644 --- a/wercker.yml +++ b/wercker.yml @@ -13,11 +13,17 @@ build: deploy: steps: - script: - name: get version from VERSION file - code: export VERSION=$(cat VERSION) + name: get highest version from tags + code: export VERSION=$(sh incrementVersion.sh) + - script: + name: add new annotated tag + code: git tag -a $VERSION -m "Tagging release version $VERSION" + - script: + name: push newly added tag + code: git push origin $VERSION - github-create-release: token: $GITHUB_TOKEN - tag: v$VERSION + tag: $VERSION - github-upload-asset: token: $GITHUB_TOKEN file: launch