Skip to content

Commit

Permalink
Allow to override build date with SOURCE_DATE_EPOCH
Browse files Browse the repository at this point in the history
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 only works with GNU date.

This PR was done while working on reproducible builds for openSUSE.
  • Loading branch information
bmwiedemann committed Aug 7, 2020
1 parent cf1ff33 commit bb967bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ RM = rm
BINPATH := $(abspath ./bin)
GOBINPATH := $(shell $(GO) env GOPATH)/bin
COMMIT := $(shell git rev-parse HEAD)
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))
else
BUILD_DATE ?= $(shell date $(DATE_FMT))
endif
# TAG can be provided as an envvar (provided in the .spec file)
TAG ?= $(shell git describe --tags --exact-match HEAD 2> /dev/null)
# CLOSEST_TAG can be provided as an envvar (provided in the .spec file)
Expand Down

0 comments on commit bb967bf

Please sign in to comment.