Skip to content

Commit ff7e564

Browse files
committed
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.
1 parent cf3cd0b commit ff7e564

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

Tools/utils.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,9 @@ function get_short_version() {
2222
if [ $COMMIT_COUNT_SINCE_TAG = 0 ]; then
2323
SHORT_VERSION="$LATEST_TAG"
2424
else
25-
# increment final digit of tag and append "d" + commit-count-since-tag
26-
# e.g. commit after 1.0 is 1.1d1, commit after 1.0.0 is 1.0.1d1
27-
# this is the bit that requires /bin/bash
28-
OLD_IFS=$IFS
29-
IFS="."
30-
VERSION_PARTS=($LATEST_TAG)
31-
LAST_PART=$((${#VERSION_PARTS[@]}-1))
32-
VERSION_PARTS[$LAST_PART]=$((${VERSION_PARTS[${LAST_PART}]}+1))
33-
SHORT_VERSION="${VERSION_PARTS[*]}d${COMMIT_COUNT_SINCE_TAG}"
34-
IFS=$OLD_IFS
25+
local tools_dir=$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")
26+
local next_version=$(cat "$tools_dir/version.txt")
27+
SHORT_VERSION="${next_version}d${COMMIT_COUNT_SINCE_TAG}"
3528
fi
3629
echo $SHORT_VERSION
3730
}

Tools/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.8.0

0 commit comments

Comments
 (0)