forked from apps/featurer
43 lines
888 B
Bash
43 lines
888 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
VERSION_PREFIX="v"
|
||
|
|
||
|
# shellcheck disable=SC1083
|
||
|
BUILD_NUMBER=$(git rev-list --count --all)
|
||
|
BRANCH_NAME=$(git branch --show-current)
|
||
|
COMMIT=$(git rev-parse HEAD)
|
||
|
VERSION=$(git tag | sort | grep "${VERSION_PREFIX}" | tail -n 1 | cut -c$((${#VERSION_PREFIX} + 1))-)
|
||
|
|
||
|
if [ "${VERSION}" == "" ]; then
|
||
|
VERSION="0.1.0-dev"
|
||
|
fi
|
||
|
|
||
|
function show_help() {
|
||
|
echo "$0 [param]"
|
||
|
echo ""
|
||
|
echo "Parameters:"
|
||
|
echo ""
|
||
|
echo " branch Show branch."
|
||
|
echo " build_number Show build number (commits count)."
|
||
|
echo " commit Show commit hash."
|
||
|
echo " version Show version (real or '0.1.0-dev' if no version tags present)."
|
||
|
}
|
||
|
|
||
|
case $1 in
|
||
|
branch)
|
||
|
echo "${BRANCH_NAME}"
|
||
|
;;
|
||
|
build_number)
|
||
|
echo "${BUILD_NUMBER}"
|
||
|
;;
|
||
|
commit)
|
||
|
echo "${COMMIT}"
|
||
|
;;
|
||
|
version)
|
||
|
echo "${VERSION}"
|
||
|
;;
|
||
|
*)
|
||
|
show_help
|
||
|
;;
|
||
|
esac
|