Files
glorytun/version.sh
Frank Denis a50882e1ac Cope with branches that don't have tags
`version.sh` used to return only the hash of the last commit, causing
VERSION_MAJOR to possibly contain non-numeric junk.
2016-01-16 15:37:42 +01:00

15 lines
382 B
Bash
Executable File

#!/bin/sh
[ -z "${VERSION}" ] && VERSION=`git describe --tags --always 2>/dev/null | \
fgrep .` \
&& VERSION=${VERSION#v}
[ -z "${VERSION}" ] && VERSION=`cat VERSION 2>/dev/null`
[ -z "${VERSION}" ] && VERSION=0.0.0
[ "$1" = "major" ] && printf ${VERSION%%.*} \
&& exit 0
printf ${VERSION} | tee VERSION