Skip to content

Commit

Permalink
Track version number for next release in file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
FranklinYu committed Feb 21, 2020
1 parent cf3cd0b commit ff7e564
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Tools/utils.sh
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions Tools/version.txt
@@ -0,0 +1 @@
0.8.0

0 comments on commit ff7e564

Please sign in to comment.