44# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66VERSION ?= main
7- BUILD_DATE := $(shell date +% Y-% m-% d\ % H:% M)
8- TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
9- TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
10- BUILD_SHA := $(shell git rev-parse --short HEAD)
11- BUILD_VERSION := $(TAG:v%=% )
12- ifneq ($(COMMIT ) , $(TAG_COMMIT ) )
13- BUILD_VERSION := $(BUILD_VERSION)-$(BUILD_SHA)
14- endif
15- ifneq ($(shell git status --porcelain) ,)
16- BUILD_VERSION := $(BUILD_VERSION)-dirty
17- endif
187
198# Go architecture and targets images to build
209GOARCH ?= amd64
@@ -41,18 +30,20 @@ endif
4130# Image URL to use all building/pushing image targets
4231IMAGE ?= ${IMAGE_TAG_BASE}:${VERSION}
4332
44- OCI_BUILD_OPTS ?=
45-
4633# Image building tool (docker / podman) - docker is preferred in CI
4734OCI_BIN_PATH = $(shell which docker 2>/dev/null || which podman)
4835OCI_BIN ?= $(shell basename ${OCI_BIN_PATH})
36+ OCI_BUILD_OPTS ?=
37+
38+ ifneq ($(CLEAN_BUILD ) ,)
39+ BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M)
40+ BUILD_SHA := $(shell git rev-parse --short HEAD)
41+ LDFLAGS ?= -X 'main.buildVersion=${VERSION}-${BUILD_SHA}' -X 'main.buildDate=${BUILD_DATE}'
42+ endif
4943
5044GOLANGCI_LINT_VERSION = v1.53.3
5145NPM_INSTALL ?= install
5246CMDLINE_ARGS ?= --loglevel trace --config config/config.yaml
53- LDFLAGS := -X 'main.buildVersion=${BUILD_VERSION}' -X 'main.buildDate=${BUILD_DATE}'
54- # You can add GO Build flags like -gcflags=all="-N -l" here to remove optimizations for debugging
55- BUILD_FLAGS ?= -ldflags "${LDFLAGS}"
5647
5748.DEFAULT_GOAL := help
5849
0 commit comments