ob-charts-tool/scripts/version

32 lines
674 B
Bash
Executable File

#!/bin/bash
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
fi
COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=$(git tag -l --contains HEAD | head -n 1)
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
fi
ARCH=$TARGET_ARCH
if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi
TAG=${TAG:-${VERSION}}
REPO=${REPO:-rancher}
if echo "$TAG" | grep -q dirty; then
TAG="v0.0.0-dev.1-${COMMIT}"
fi
function print_version_debug() {
echo "DIRTY: ${DIRTY:-"Not DIRTY"}"
echo "REPO: $REPO; TAG: $TAG";
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then print_version_debug "$1"; fi