From 5c41924b2f690e8e09c6a9f5487124968e162810 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Mon, 13 Sep 2021 13:49:21 +0300 Subject: [PATCH] Add version arg to make build Allow specifying the version when building the CLI binary with Make. This is useful for projects that distribute their own Flux CLI binary. Signed-off-by: Stefan Prodan --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a3645cd4..6426e7a2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | tr -d '"') +VERSION?=$(shell grep 'VERSION' cmd/flux/main.go | awk '{ print $$4 }' | head -n 1 | tr -d '"') EMBEDDED_MANIFESTS_TARGET=cmd/flux/manifests TEST_KUBECONFIG?=/tmp/flux-e2e-test-kubeconfig ENVTEST_BIN_VERSION?=latest @@ -48,7 +48,7 @@ $(EMBEDDED_MANIFESTS_TARGET): $(call rwildcard,manifests/,*.yaml *.json) ./manifests/scripts/bundle.sh build: $(EMBEDDED_MANIFESTS_TARGET) - CGO_ENABLED=0 go build -o ./bin/flux ./cmd/flux + CGO_ENABLED=0 go build -ldflags="-s -w -X main.VERSION=$(VERSION)" -o ./bin/flux ./cmd/flux install: go install cmd/flux