From ce7a8dde83e442dbbfb4bfc523e375645ed36361 Mon Sep 17 00:00:00 2001 From: jelle van der Waa Date: Mon, 9 Sep 2019 07:30:48 +0200 Subject: [PATCH] Build: Support SOURCE_DATE_EPOCH for reproducible builds (#18953) If grafana is build from a non-git source a new timestamp is used every build which makes grafana binaries non-reproducible. Motivation: https://reproducible-builds.org --- build.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.go b/build.go index 6cfa79ea750..16cad86456a 100644 --- a/build.go +++ b/build.go @@ -592,6 +592,11 @@ func getGitSha() string { } func buildStamp() int64 { + // use SOURCE_DATE_EPOCH if set. + if s, _ := strconv.ParseInt(os.Getenv("SOURCE_DATE_EPOCH"), 10, 64); s > 0 { + return s + } + bs, err := runError("git", "show", "-s", "--format=%ct") if err != nil { return time.Now().Unix()