Fix incorrect version number output

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich 2021-02-18 15:16:48 -05:00
parent de8243453d
commit e296b6023e
No known key found for this signature in database
GPG Key ID: 03EDC70FD578067F
1 changed files with 9 additions and 1 deletions

View File

@ -14,11 +14,19 @@ valid_args() {
cut -d '*' -f 1
}
# `git describe` does not reliably produce a useful version number.
scrape_version() {
local versionfile='version/version.go'
local version_line=$(grep -m 1 'var Version =' $versionfile)
local version_string=$(cut -d '"' -f 2 <<<"$version_line")
echo "$version_string" | tr -d '[:space:]'
}
unset OUTPUT
case "$1" in
# Wild-card suffix needed by valid_args() e.g. possible bad grep of "$(echo $FOO)"
VERSION*)
OUTPUT="${CIRRUS_TAG:-$(git fetch --tags && git describe HEAD 2> /dev/null)}"
OUTPUT="${CIRRUS_TAG:-$(scrape_version)}"
;;
NUMBER*)
OUTPUT="$($0 VERSION | sed 's/-.*//')"