Skip to content

Commit

Permalink
Dirty determination outside docker
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Dec 8, 2023
1 parent d478b0d commit 870ee0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
-e IMAGE_NAME -e DRONE_TAG -e DIRTY=$(DIRTY) kine-package
3 changes: 2 additions & 1 deletion scripts/version
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 870ee0f

Please sign in to comment.