From 1284ee479e7b3b5a066db1061a2026bfa98f7098 Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Sun, 25 Jul 2021 17:36:45 -0500 Subject: [PATCH] Fix tag matching Only use tags that start with v, e.g. v1.2.3, when determining the current version from git for tagged builds. Ignore stuff like latest and canary. Signed-off-by: Carolyn Van Slyck --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 224cc5f..e8497f2 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,8 @@ GO = GO111MODULE=on go PORTER_HOME ?= $(HOME)/.porter COMMIT ?= $(shell git rev-parse --short HEAD) -VERSION ?= $(shell git describe --tags 2> /dev/null || echo v0) -PERMALINK ?= $(shell git describe --tags --exact-match &> /dev/null && echo latest || echo canary) +VERSION ?= $(shell git describe --tags --match=v* 2> /dev/null || echo v0) +PERMALINK ?= $(shell git describe --tags --match=v* --exact-match &> /dev/null && echo latest || echo canary) LDFLAGS = -w -X $(PKG)/pkg.Version=$(VERSION) -X $(PKG)/pkg.Commit=$(COMMIT) XBUILD = CGO_ENABLED=0 $(GO) build -a -tags netgo -ldflags '$(LDFLAGS)'