Allow to override build date with SOURCE_DATE_EPOCH

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.

Also use UTC to be independent of timezone.
This commit is contained in:
Bernhard M. Wiedemann 2020-07-08 05:05:52 +02:00
parent e4a8c9f639
commit 29df24fa6c

2
build
View File

@ -19,7 +19,7 @@ if [ -z "$VERSION" ]; then
fi
set -e
fi
DATE=$(date --iso-8601=seconds)
DATE=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --iso-8601=seconds)
COMMIT=${COMMIT:-$(git rev-parse --verify HEAD)}
LDFLAGS="-X main.version=${VERSION:-master} -X main.commit=${COMMIT} -X main.date=${DATE}"
export CGO_ENABLED=0