30 lines
678 B
Bash
Executable File
30 lines
678 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
VERSION_PREFIX=
|
|
|
|
# Gits the current git tag (if any)
|
|
TAG=$(git tag -l --points-at HEAD)
|
|
|
|
RECENT_TAG=$(git describe --tags)
|
|
|
|
DATE=$(TZ=UTC date +"%Y%m%d%H%M%S")
|
|
|
|
COMMIT_HASH=$(git rev-parse --short HEAD)
|
|
|
|
|
|
## If working tree is not clean, append {RECENT_TAG}+
|
|
if [[ $(git status -u -s) ]]; then
|
|
VERSION_STRING=${VERSION_PREFIX}${RECENT_TAG}+
|
|
|
|
# If working tree is clean, but head is not tagged append a git description
|
|
elif [[ ! ${TAG} ]]; then
|
|
VERSION_STRING=${VERSION_PREFIX}${RECENT_TAG}
|
|
|
|
# if working tree is clean and HEAD is tagged, this is an official version
|
|
else
|
|
VERSION_STRING=${VERSION_PREFIX}${TAG}
|
|
fi
|
|
|
|
echo "-D VERSION='\"${VERSION_STRING}\"'"
|
|
|