mirror of
https://github.com/securego/gosec.git
synced 2024-12-24 03:25:53 +00:00
Allow to override build date with SOURCE_DATE_EPOCH (#887)
in order to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This date call works with different variants of date. Also use UTC to be independent of timezone.
This commit is contained in:
parent
26f038913f
commit
a7ad827c42
1 changed files with 6 additions and 1 deletions
7
Makefile
7
Makefile
|
@ -2,7 +2,12 @@ GIT_TAG?= $(shell git describe --always --tags)
|
|||
BIN = gosec
|
||||
FMT_CMD = $(gofmt -s -l -w $(find . -type f -name '*.go' -not -path './vendor/*') | tee /dev/stderr)
|
||||
IMAGE_REPO = securego
|
||||
BUILD_DATE ?= $(shell date +%Y-%m-%d)
|
||||
DATE_FMT=+%Y-%m-%d
|
||||
ifdef SOURCE_DATE_EPOCH
|
||||
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
|
||||
else
|
||||
BUILD_DATE ?= $(shell date "$(DATE_FMT)")
|
||||
endif
|
||||
BUILDFLAGS := "-w -s -X 'main.Version=$(GIT_TAG)' -X 'main.GitTag=$(GIT_TAG)' -X 'main.BuildDate=$(BUILD_DATE)'"
|
||||
CGO_ENABLED = 0
|
||||
GO := GO111MODULE=on go
|
||||
|
|
Loading…
Reference in a new issue