another try on clean git

This commit is contained in:
Jonas Forsberg 2023-04-13 17:03:08 +02:00
parent 5be3153522
commit e75ec99fcd

View File

@ -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)