forked from XiaoMi/Gaea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_version.sh
executable file
·35 lines (29 loc) · 1022 Bytes
/
gen_version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
ROOT="$(pwd)"
if BUILD_GIT_REVISION=$(git rev-parse HEAD 2> /dev/null); then if ! git diff-index --quiet HEAD; then BUILD_GIT_REVISION=${BUILD_GIT_REVISION}"-dirty"
fi
else
BUILD_GIT_REVISION=unknown
fi
# Check for local changes
if git diff-index --quiet HEAD --; then
tree_status="Clean"
else
tree_status="Modified"
fi
# XXX This needs to be updated to accomodate tags added after building, rather than prior to builds
RELEASE_TAG=$(git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --exact-match --tags 2> /dev/null || echo "")
# security wanted VERSION='unknown'
VERSION="${BUILD_GIT_REVISION}"
if [[ -n "${RELEASE_TAG}" ]]; then
VERSION="${RELEASE_TAG}"
elif [[ -n ${MY_VERSION} ]]; then
VERSION="${MY_VERSION}"
fi
# used by pkg/version
echo buildVersion "${VERSION}"
echo buildGitRevision "${BUILD_GIT_REVISION}"
echo buildUser "$(whoami)"
echo buildHost "$(hostname -f)"
echo buildStatus "${tree_status}"
echo buildTime "$(date +%Y-%m-%d--%T)"