From 13e480c79d8a7a72f2209392e0cac851ddf5286b Mon Sep 17 00:00:00 2001 From: Stefan Reimer Date: Sun, 16 Jan 2022 00:19:44 +0100 Subject: [PATCH] feat: parse container tag from git tag --- Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index bb47c9c..a6496f9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ -VERSION ?= 0.2.2 BASE ?= latest-alpine-jdk11 REGISTRY := public.ecr.aws/zero-downtime REPOSITORY := jenkins-podman -TAG := $(REPOSITORY):v$(VERSION) + +# Parse version from latest git semver tag +GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || echo "v0.0.0") +TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//') ifeq ($(TRIVY_REMOTE),) TRIVY_OPTS := image @@ -15,12 +17,13 @@ endif all: build build: - podman build --rm --squash-all --build-arg BASE=$(BASE) -t $(TAG) . + podman build --rm --squash-all --build-arg BASE=$(BASE) -t $(REPOSITORY):latest . push: aws ecr-public get-login-password --region us-east-1 | podman login --username AWS --password-stdin $(REGISTRY) - podman tag $(TAG) $(REGISTRY)/$(TAG) - podman push $(REGISTRY)/$(TAG) + podman tag $(REPOSITORY):latest $(REGISTRY)/$(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):latest + podman push $(REGISTRY)/$(REPOSITORY):$(TAG) + podman push $(REGISTRY)/$(REPOSITORY):latest scan: trivy $(TRIVY_OPTS) $(TAG)