From ff7e56438b0353b7322f99cca35b3c6fb61f3f5d Mon Sep 17 00:00:00 2001 From: Franklin Yu Date: Thu, 20 Feb 2020 22:30:27 -0800 Subject: [PATCH] Track version number for next release in file Only major and minor version numbers. Patch numbers remains calculated. The trick to get current directory only works in Bash or Zsh. See: https://stackoverflow.com/questions/9901210/bash-source0-equivalent-in-zsh#54755784 Note that "$0" won't work since the script is sourced, not executed. --- Tools/utils.sh | 13 +++---------- Tools/version.txt | 1 + 2 files changed, 4 insertions(+), 10 deletions(-) create mode 100644 Tools/version.txt diff --git a/Tools/utils.sh b/Tools/utils.sh index a27af0e5..1d153b48 100644 --- a/Tools/utils.sh +++ b/Tools/utils.sh @@ -22,16 +22,9 @@ function get_short_version() { if [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then SHORT_VERSION="$LATEST_TAG" else - # increment final digit of tag and append "d" + commit-count-since-tag - # e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1 - # this is the bit that requires /bin/bash - OLD_IFS=$IFS - IFS="." - VERSION_PARTS=($LATEST_TAG) - LAST_PART=$((${#VERSION_PARTS[@]}-1)) - VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1)) - SHORT_VERSION="${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}" - IFS=$OLD_IFS + local tools_dir=$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}") + local next_version=$(cat "$tools_dir/version.txt") + SHORT_VERSION="${next_version}d${COMMIT_COUNT_SINCE_TAG}" fi echo $SHORT_VERSION } diff --git a/Tools/version.txt b/Tools/version.txt new file mode 100644 index 00000000..a3df0a69 --- /dev/null +++ b/Tools/version.txt @@ -0,0 +1 @@ +0.8.0