Merge pull request #2641 from ashish-amarnath/reorg-build

🏃‍♂️ pass git state to build from makefile
This commit is contained in:
Nolan Brubaker
2020-06-17 12:40:22 -04:00
committed by GitHub
2 changed files with 13 additions and 2 deletions

View File

@@ -40,6 +40,10 @@ CLI_PLATFORMS ?= linux-amd64 linux-arm linux-arm64 darwin-amd64 windows-amd64 li
CONTAINER_PLATFORMS ?= linux-amd64 linux-ppc64le linux-arm linux-arm64 CONTAINER_PLATFORMS ?= linux-amd64 linux-ppc64le linux-arm linux-arm64
MANIFEST_PLATFORMS ?= amd64 ppc64le arm arm64 MANIFEST_PLATFORMS ?= amd64 ppc64le arm arm64
# set git sha and tree state
GIT_SHA = $(shell git rev-parse HEAD)
GIT_DIRTY = $(shell git status --porcelain 2> /dev/null)
### ###
### These variables should not need tweaking. ### These variables should not need tweaking.
### ###
@@ -113,6 +117,8 @@ local: build-dirs
VERSION=$(VERSION) \ VERSION=$(VERSION) \
PKG=$(PKG) \ PKG=$(PKG) \
BIN=$(BIN) \ BIN=$(BIN) \
GIT_SHA=$(GIT_SHA) \
GIT_DIRTY="$(GIT_DIRTY)" \
OUTPUT_DIR=$$(pwd)/_output/bin/$(GOOS)/$(GOARCH) \ OUTPUT_DIR=$$(pwd)/_output/bin/$(GOOS)/$(GOARCH) \
./hack/build.sh ./hack/build.sh
@@ -126,6 +132,8 @@ _output/bin/$(GOOS)/$(GOARCH)/$(BIN): build-dirs
VERSION=$(VERSION) \ VERSION=$(VERSION) \
PKG=$(PKG) \ PKG=$(PKG) \
BIN=$(BIN) \ BIN=$(BIN) \
GIT_SHA=$(GIT_SHA) \
GIT_DIRTY=\"$(GIT_DIRTY)\" \
OUTPUT_DIR=/output/$(GOOS)/$(GOARCH) \ OUTPUT_DIR=/output/$(GOOS)/$(GOARCH) \
./hack/build.sh'" ./hack/build.sh'"

View File

@@ -39,10 +39,13 @@ if [ -z "${VERSION}" ]; then
exit 1 exit 1
fi fi
if [ -z "${GIT_SHA}" ]; then
echo "GIT_SHA must be set"
exit 1
fi
export CGO_ENABLED=0 export CGO_ENABLED=0
GIT_SHA=$(git rev-parse HEAD)
GIT_DIRTY=$(git status --porcelain 2> /dev/null)
if [[ -z "${GIT_DIRTY}" ]]; then if [[ -z "${GIT_DIRTY}" ]]; then
GIT_TREE_STATE=clean GIT_TREE_STATE=clean
else else