From e75ec99fcd93872380c389fcf3d6f9d6865a4e55 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Thu, 13 Apr 2023 17:03:08 +0200 Subject: [PATCH] another try on clean git --- Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 63b8658..49bd9c8 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: default build clean release +.PHONY: default build clean release require_clean_git -include .env @@ -10,16 +10,25 @@ SHELL := /bin/bash default: build -guard: - @ if [ -z "$(git status --porcelain=v1 2>/dev/null)" ]; then echo "git not clean!"; exit 1; fi +require_clean_git: + git update-index -q --ignore-submodules --refresh + git diff-files --quiet --ignore-submodules + git diff-index --cached --quiet --ignore-submodules HEAD -- + @status=$$(git status --porcelain); \ + if test "x$${status}" = x; then \ + echo "No files" \ + else \ + echo "Untracked files" \ + exit 1 \ + fi build: podman build --build-arg VERSION=$(VERSION) --tag ${REPO}/${IMAGENAME}:$(VERSION) . -clean: guard +clean: podman image rm ${REPO}/${IMAGENAME}:$(VERSION) -release: guard build +release: require_clean_git build $(eval TMP_MESSAGE := $(shell podman run --rm -it ${REPO}/${IMAGENAME}:$(VERSION) /usr/sbin/dnsmasq --version)) git tag -a v$(VERSION) -m "${TMP_MESSAGE}" git push origin v$(VERSION)