forked from github/multus-cni
build: Allow to define VERSION and COMMIT without git
Previously the build script required git to be used and installed which did not allow to build Multus from a tarball which doesn't contain .git directory. That made packaging of Multus hard. Example usage after the change if you do not want to use git: ``` $ VERSION=v3.3 COMMIT=ba33df ./build ``` Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
This commit is contained in:
parent
8bdb7104d7
commit
84c348ce18
4
build
4
build
@ -9,6 +9,7 @@ fi
|
|||||||
|
|
||||||
# Add version/commit/date into binary
|
# Add version/commit/date into binary
|
||||||
# In case of TravisCI, need to check error code of 'git describe'.
|
# In case of TravisCI, need to check error code of 'git describe'.
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
set +e
|
set +e
|
||||||
git describe --tags --abbrev=0 > /dev/null 2>&1
|
git describe --tags --abbrev=0 > /dev/null 2>&1
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
@ -17,8 +18,9 @@ else
|
|||||||
VERSION=$(git describe --tags --abbrev=0)
|
VERSION=$(git describe --tags --abbrev=0)
|
||||||
fi
|
fi
|
||||||
set -e
|
set -e
|
||||||
|
fi
|
||||||
DATE=$(date --iso-8601=seconds)
|
DATE=$(date --iso-8601=seconds)
|
||||||
COMMIT=$(git rev-parse --verify HEAD)
|
COMMIT=${COMMIT:-$(git rev-parse --verify HEAD)}
|
||||||
LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}"
|
LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}"
|
||||||
export CGO_ENABLED=0
|
export CGO_ENABLED=0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user