1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-30 23:37:49 +02:00

Set all version flags at build time so they have correct values (#593)

This commit is contained in:
David Jimenez
2021-10-15 09:35:15 +01:00
committed by GitHub
parent c0f2d40eaa
commit b331445a16
3 changed files with 9 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ builds:
-
env:
- CGO_ENABLED=0
- BUILDER=GoReleaser
goos:
- linux
- darwin

View File

@@ -2,11 +2,17 @@
export GO111MODULE=on
GIT_COMMIT ?= $(shell git rev-parse --verify HEAD)
GIT_VERSION ?= $(shell git describe --tags --always --dirty="-dev")
DATE ?= $(shell date -u '+%Y-%m-%d %H:%M UTC')
BUILDER ?= Makefile
VERSION_FLAGS := -X "main.version=$(GIT_VERSION)" -X "main.date=$(DATE)" -X "main.commit=$(GIT_COMMIT)" -X "main.builtBy=$(BUILDER)"
install:
@go mod vendor
build:
@go build
@go build -ldflags='$(VERSION_FLAGS)'
test:
@go test -v ./...

View File

@@ -214,7 +214,7 @@ func init() {
// Output build info (version, commit, date and builtBy)
if versionFlag {
fmt.Printf(
"Current revive version %v commit %v, built @%v by %v.\n",
"Version:\t%s\nCommit:\t\t%s\nBuilt\t\t%s by %s\n",
version,
commit,
date,