Set version in Makefile when installing

This commit is contained in:
Leigh McCulloch 2018-09-18 05:02:01 +00:00
parent 0b86ec0579
commit e198d3eb36
2 changed files with 5 additions and 2 deletions

View File

@ -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:

View File

@ -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)
}