feat: parse container tag from git tag

This commit is contained in:
Stefan Reimer 2022-01-16 00:19:44 +01:00
parent 316579933d
commit 13e480c79d

View File

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