diff --git a/podman.mk b/podman.mk index 55cff91..2ab4469 100644 --- a/podman.mk +++ b/podman.mk @@ -1,11 +1,13 @@ # Parse version from latest git semver tag -BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) +GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) GIT_TAG := $(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null) -TAG := $(GIT_TAG) # append branch name to tag if NOT main nor master -ifeq (,$(filter main master, $(BRANCH))) - TAG = $(GIT_TAG)-$(BRANCH) +TAG := $(GIT_TAG) +ifeq (,$(filter main master, $(GIT_BRANCH))) + ifneq ($(GIT_TAG), $(GIT_BRANCH)) + TAG = $(GIT_TAG)-$(GIT_BRANCH) + endif endif # optionally set by the caller @@ -68,13 +70,13 @@ rm-remote-untagged: ## delete all remote untagged images [ -n "$$IMAGE_IDS" ] && aws ecr-public batch-delete-image --repository-name $(IMAGE) --region $(REGION) --image-ids $$IMAGE_IDS || echo "No image to remove" rm-image: - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH) > /dev/null - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || echo "Error: Removing image failed" + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH) > /dev/null + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH))" || echo "Error: Removing image failed" # Ensure we run the tests by removing any previous runs rm-test-image: - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH)-test > /dev/null - test -z "$$(docker image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || echo "Error: Removing test image failed" + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || podman image rm -f $(IMAGE):$(TAG)-$(_ARCH)-test > /dev/null + test -z "$$(podman image ls -q $(IMAGE):$(TAG)-$(_ARCH)-test)" || echo "Error: Removing test image failed" ci-pull-upstream: ## pull latest shared .ci subtree git stash && git subtree pull --prefix .ci ssh://git@git.zero-downtime.net/ZeroDownTime/ci-tools-lib.git master --squash && git stash pop