From 82a8977c96f3d2f39442758bc8291cb3d2727613 Mon Sep 17 00:00:00 2001 From: Amine Date: Tue, 13 Nov 2018 20:24:06 +0100 Subject: [PATCH] Closes #244. --- build.sh | 26 +++++++++++++++++++++----- publish-version-local.sh | 9 +++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100755 publish-version-local.sh diff --git a/build.sh b/build.sh index 0304611..ff2fd46 100755 --- a/build.sh +++ b/build.sh @@ -1,17 +1,33 @@ #!/bin/bash BASE_VERSION="1.7" -TODAYS_VERSION="1" +LAST_TAG=$(git tag -l | sort -V | tail -1) -VERSION="${BASE_VERSION//./}$(date '+%y%m%j')$TODAYS_VERSION" +INITIAL_VERSION="${BASE_VERSION//./}$(date '+%y%m%j')" -PARAMS_EXCEPT_PUBLISH=$(echo $1 | sed 's/\-\-publish//') +LAST_DAY_VERSION=$(echo $LAST_TAG | sed "s/v${INITIAL_VERSION}//") +LAST_DAY_VERSION_LENGTH=$(echo "${#LAST_DAY_VERSION}") + +if [[ "$LAST_DAY_VERSION_LENGTH" == "1" ]] +then + TODAYS_VERSION=$(( $LAST_DAY_VERSION + 1 )) +else + TODAYS_VERSION="1" +fi + +VERSION="${INITIAL_VERSION}${TODAYS_VERSION}" + +PARAMS_EXCEPT_PUBLISH_LOCAL=$(echo $1 | sed 's/\-\-publish\-local//') +PARAMS_EXCEPT_PUBLISH=$(echo $PARAMS_EXCEPT_PUBLISH_LOCAL | sed 's/\-\-publish//') ./version.sh ${VERSION} ${PARAMS_EXCEPT_PUBLISH} -if [[ "$@" == *'--publish'* ]] +if [[ "$@" == *'--publish-local'* ]] +then + ./publish-version-local.sh ${VERSION} +elif [[ "$@" == *'--publish'* ]] then ./publish-version.sh ${VERSION} else - echo "Did not publish. If you wanted to do so, call the script with \"--publish\"." + echo "Did not publish. If you wanted to do so, call the script with \"--publish\" or \"--publish-local\"." fi diff --git a/publish-version-local.sh b/publish-version-local.sh new file mode 100755 index 0000000..25ad841 --- /dev/null +++ b/publish-version-local.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +rm -f version.txt +printf "versionName=$1-github\nversionCode=$1" >> version.txt + +# You'll need to change server as your server and define a VERSION_PATH. +cp version.txt $VERSION_PATH + +rm version.txt