Skip to content

Commit f8dee18

Browse files
committed
Respect SOURCE_DATE_EPOCH when building
To make the build reproducable (see [0]), respect the SOURCE_DATE_EPOCH variable and don't include a build timestammp in the binary when set. [0] https://reproducible-builds.org/
1 parent 30846f8 commit f8dee18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ LAST_COMMIT := $(or $(shell git rev-parse --short HEAD 2> /dev/null),$(shell hea
44
# Try to get the semver from 1) git 2) the VERSION file 3) fallback.
55
VERSION := $(or $(LISTMONK_VERSION),$(shell git describe --tags --abbrev=0 2> /dev/null),$(shell grep -oP 'tag: \Kv\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?' VERSION),"v0.0.0")
66

7-
BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
7+
ifdef SOURCE_DATE_EPOCH
8+
BUILDSTR := ${VERSION} (\#${LAST_COMMIT}
9+
else
10+
BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
11+
endif
812

913
YARN ?= yarn
1014
GOPATH ?= $(HOME)/go

0 commit comments

Comments
 (0)