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)