kube-explorer/scripts/version
2024-09-26 09:49:16 +08:00

23 lines
467 B
Bash
Executable File

#!/bin/bash
if [[ ${GITHUB_REF} == refs/tags/* ]]; then
DRONE_TAG=${DRONE_TAG:-${GITHUB_REF#refs/tags/}}
fi
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)}
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="${COMMIT}${DIRTY}"
fi
if [ -z "$ARCH" ]; then
ARCH=$(go env GOHOSTARCH)
fi