1
0
mirror of https://github.com/rancher/os.git synced 2025-08-20 15:52:53 +00:00
os/scripts/version

42 lines
791 B
Plaintext
Raw Normal View History

2021-08-31 18:14:03 +00:00
#!/bin/bash
2021-10-20 17:58:54 +00:00
if [ -e .git ] || [ -e ../.git ]; then
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
fi
COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=${DRONE_TAG:-$(git tag -l --contains HEAD | head -n 1)}
else
COMMIT=HEAD
GIT_TAG=HEAD
2021-08-31 18:14:03 +00:00
DIRTY="-dirty"
fi
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
fi
if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi
SUFFIX="-${ARCH}"
2021-10-20 17:58:54 +00:00
HELM_TAG=${TAG:-${VERSION}}
HELM_VERSION=${HELM_TAG/v/}
2021-08-31 18:14:03 +00:00
TAG=${TAG:-${VERSION}${SUFFIX}}
REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev
2021-10-20 17:58:54 +00:00
HELM_TAG=dev
HELM_VERSION=0.0.0-dev
fi
if echo "$HELM_VERSION" | grep -q '^[^0-9]'; then
HELM_VERSION=0.0.0-dev
2021-08-31 18:14:03 +00:00
fi