diff --git a/Makefile b/Makefile index 0ea295e0..0bb2269b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,11 @@ $(TARGETS): .dapper ARCH ?= amd64 REPO ?= rancher -DEFAULT_BUILD_ARGS=--build-arg="REPO=$(REPO)" --build-arg="TAG=$(TAG)" --build-arg="ARCH=$(ARCH)" +DEFAULT_BUILD_ARGS=--build-arg="REPO=$(REPO)" --build-arg="TAG=$(TAG)" --build-arg="ARCH=$(ARCH)" --build-arg="DIRTY=$(DIRTY)" +DIRTY := $(shell git status --porcelain --untracked-files=no) +ifneq ($(DIRTY),) + DIRTY="-dirty" +endif .PHONY: no-dapper no-dapper: @@ -26,4 +30,4 @@ no-dapper: -f Dockerfile --target=binary --output=. . DOCKER_BUILDKIT=1 docker build -t kine-package -f Dockerfile --target=package . DOCKER_BUILDKIT=1 docker run -v /var/run/docker.sock:/var/run/docker.sock -v ./dist:/go/src/github.com/k3s-io/kine/dist \ - -e IMAGE_NAME -e DRONE_TAG kine-package \ No newline at end of file + -e IMAGE_NAME -e DRONE_TAG -e DIRTY=$(DIRTY) kine-package \ No newline at end of file diff --git a/scripts/version b/scripts/version index 8d196f17..78a02b08 100755 --- a/scripts/version +++ b/scripts/version @@ -1,6 +1,7 @@ #!/bin/bash -if [ -n "$(git status --porcelain --untracked-files=no)" ]; then +# Without Dapper, DIRTY is determined in the Makefile and passed in as a build arg/env var +if [ -z "$DIRTY" ] && [ -n "$(git status --porcelain --untracked-files=no)" ]; then DIRTY="-dirty" fi