From ade3ae5e99fb6ce5c58ffe90e7c90b86579043aa Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 9 Jun 2024 10:09:36 -0600 Subject: [PATCH] Get version info from git Instead of manually setting version in Makefile, use $(git describe --tags) which shows the most recent tag, number of revisions since that tag, and short hash of current commit. Can also get more version info form the binary with `go version gsheet` --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ca1e4bd..ce7c34f 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ -version := v0.1.4 +version := $(shell git describe --tags) +ldflags := '-s -w -X main.version=${version}' platforms := linux_386 linux_amd64 darwin_amd64 windows_386 windows_amd64 SHELL := /bin/bash .PHONY: build build: - go build -o gsheet ./cmd/gsheet/ + go build -ldflags ${ldflags} -o gsheet ./cmd/gsheet/ .PHONY: test test: