From 4d3074fa1411efe23f6d663becc7d6b082c3c1bb Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Tue, 2 Mar 2021 00:41:55 -0600 Subject: [PATCH] Use LDFLAGS to set build version --- Makefile | 7 +++++-- cmd/main.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1a47632..b04a7ae 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +LUME_VERSION ?= $(shell git describe --tags --always) +LDFLAGS := ${LDFLAGS} -X git.kill0.net/chill9/lume/cmd.Version=${LUME_VERSION} + ifeq ($(OS), Windows_NT) EXE=lume.exe RM=del /f /q @@ -8,8 +11,8 @@ endif .PHONY: build build: - go build -o ${EXE} ./cmd/lume + go build -o ${EXE} -ldflags="${LDFLAGS}" ./cmd/lume .PHONY: clean clean: - ${RM} ${EXE} + ${RM} ${EXE} \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go index 4c46407..527f040 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -29,7 +29,7 @@ func init() { RegisterCommand(NewCmdVersion()) } -const Version = "0.1.0-pre" +var Version string = "0.1.0-pre" const lumercFile string = ".lumerc"