From e198d3eb367903a84e51f4eab595199e59a946f2 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch Date: Tue, 18 Sep 2018 05:02:01 +0000 Subject: [PATCH] Set version in Makefile when installing --- Makefile | 5 ++++- cmd/grpcurl/grpcurl.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 42a9a30..0313116 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ # violations already in the code). They can be useful to catch errors, but # they are just too noisy to be a requirement for a CI -- we don't even *want* # to fix some of the things they consider to be violations. + +version=$(shell git describe --always --dirty) + .PHONY: ci ci: deps checkgofmt vet staticcheck unused ineffassign predeclared test @@ -16,7 +19,7 @@ updatedeps: .PHONY: install install: - go install ./... + go install -ldflags '-X "main.version=dev build $(version)"' ./... .PHONY: checkgofmt checkgofmt: diff --git a/cmd/grpcurl/grpcurl.go b/cmd/grpcurl/grpcurl.go index 58f5bde..6d4d053 100644 --- a/cmd/grpcurl/grpcurl.go +++ b/cmd/grpcurl/grpcurl.go @@ -151,7 +151,7 @@ func main() { os.Exit(0) } if *printVersion { - fmt.Fprintf(os.Stderr, "%s v%s\n", os.Args[0], version) + fmt.Fprintf(os.Stderr, "%s %s\n", os.Args[0], version) os.Exit(0) }