build.sh: only set git commit info for dev builds

This commit fixes a problem where `make bin` would strip of any prerelease info.
This commit is contained in:
Sander van Harmelen 2019-02-06 09:41:39 +01:00
parent a9274beaca
commit 03e82687d6
1 changed files with 6 additions and 6 deletions

View File

@ -26,9 +26,12 @@ rm -rf pkg/*
mkdir -p bin/
# If its dev mode, only build for ourself
if [ "${TF_DEV}x" != "x" ]; then
if [[ -n "${TF_DEV}" ]]; then
XC_OS=$(go env GOOS)
XC_ARCH=$(go env GOARCH)
# Allow LD_FLAGS to be appended during development compilations
LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} $LD_FLAGS"
fi
if ! which gox > /dev/null; then
@ -36,15 +39,12 @@ if ! which gox > /dev/null; then
go get -u github.com/mitchellh/gox
fi
# instruct gox to build statically linked binaries
# Instruct gox to build statically linked binaries
export CGO_ENABLED=0
# Allow LD_FLAGS to be appended during development compilations
LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} $LD_FLAGS"
# In release mode we don't want debug information in the binary
if [[ -n "${TF_RELEASE}" ]]; then
LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/hashicorp/terraform/version.Prerelease= -s -w"
LD_FLAGS="-s -w"
fi
# Ensure all remote modules are downloaded and cached before build so that