@@ -9,6 +9,14 @@ RELEASE_CMD=$(TEMPDIR)/goreleaser release --rm-dist
99SNAPSHOT_CMD =$(RELEASE_CMD ) --skip-publish --snapshot
1010VERSION =$(shell git describe --dirty --always --tags)
1111
12+ # https://reproducible-builds.org/docs/source-date-epoch/
13+ DATE_FMT = +%Y-%m-%dT%H:%M:%SZ
14+ ifdef SOURCE_DATE_EPOCH
15+ 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 ) ")
16+ else
17+ BUILD_DATE ?= $(shell date "$(DATE_FMT ) ")
18+ endif
19+
1220# formatting variables
1321BOLD := $(shell tput -T linux bold)
1422PURPLE := $(shell tput -T linux setaf 5)
@@ -206,6 +214,7 @@ $(SNAPSHOTDIR): ## Build snapshot release binaries and packages
206214
207215 # build release snapshots
208216 bash -c "\
217+ BUILD_DATE=$(BUILD_DATE) \
209218 SKIP_SIGNING=true \
210219 SYFT_VERSION=$(SYFT_VERSION)\
211220 $(SNAPSHOT_CMD) --skip-sign --config $(TEMPDIR)/goreleaser.yaml"
@@ -222,7 +231,8 @@ snapshot-with-signing: ## Build snapshot release binaries and packages (with dum
222231
223232 # build release snapshots
224233 bash -c "\
225- SYFT_VERSION=$(SYFT_VERSION)\
234+ SYFT_VERSION=$(SYFT_VERSION) \
235+ BUILD_DATE=$(BUILD_DATE) \
226236 $(SNAPSHOT_CMD) --config $(TEMPDIR)/goreleaser.yaml || (cat .github/scripts/apple-signing/log/*.txt && false)"
227237
228238 # remove the keychain with the trusted self-signed cert automatically
@@ -265,6 +275,7 @@ release: clean-dist CHANGELOG.md ## Build and publish final binaries and packag
265275 # note: notarization cannot be done in parallel, thus --parallelism 1
266276 bash -c "\
267277 SYFT_VERSION=$(SYFT_VERSION)\
278+ BUILD_DATE=$(BUILD_DATE) \
268279 $(RELEASE_CMD) \
269280 --config $(TEMPDIR)/goreleaser.yaml \
270281 --parallelism 1 \
0 commit comments