From 46211ae9d39ec073834c3274a1aaa204e8186207 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Wed, 9 Dec 2020 18:58:07 +0100 Subject: [PATCH] allow overriding GIT_TAG for make build target to fix publishing docker images --- .drone.yml | 6 +++++- Dockerfile | 3 ++- Makefile | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index d23a96ae..6c90bac8 100644 --- a/.drone.yml +++ b/.drone.yml @@ -119,6 +119,8 @@ steps: from_secret: docker_username password: from_secret: docker_password + build_args: + - GIT_TAG_OVERRIDE=${DRONE_TAG} depends_on: - lint - test @@ -135,12 +137,14 @@ steps: - latest - "${DRONE_TAG}" dockerfile: Dockerfile - target: dind + target: binary-only context: . username: from_secret: docker_username password: from_secret: docker_password + build_args: + - GIT_TAG_OVERRIDE=${DRONE_TAG} depends_on: - lint - test diff --git a/Dockerfile b/Dockerfile index 2b59b8f0..423666e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM golang:1.15 as builder +ARG GIT_TAG_OVERRIDE WORKDIR /app COPY . . -RUN make build && bin/k3d version +RUN make build -e GIT_TAG_OVERRIDE=${GIT_TAG_OVERRIDE} && bin/k3d version FROM docker:19.03-dind as dind RUN apk update && apk add bash curl sudo jq git make netcat-openbsd diff --git a/Makefile b/Makefile index 4b4e41bd..1a5f72f1 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,11 @@ export GO111MODULE=on ########## Tags ########## # get git tag +ifneq ($(GIT_TAG_OVERRIDE),) +$(info GIT_TAG set from env override!) +GIT_TAG := $(GIT_TAG_OVERRIDE) +endif + GIT_TAG ?= $(shell git describe --tags) ifeq ($(GIT_TAG),) GIT_TAG := $(shell git describe --always)