aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2025-03-19 09:57:36 -0400
committerGitHub <noreply@github.com>2025-03-19 09:57:36 -0400
commitc81e938f63281dbe885f5d3e0ca842e2719de81c (patch)
tree98e1cc28b1c250ca06b130bca26f6473bfa92230 /cmd
parent8cbe801c0ce39736d1962509317506bde4eac64c (diff)
downloadanubis-c81e938f63281dbe885f5d3e0ca842e2719de81c.tar.xz
anubis-c81e938f63281dbe885f5d3e0ca842e2719de81c.zip
cmd/containerbuild: set container build timestamp to the timestamp of the commit (#15)
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/containerbuild/main.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/containerbuild/main.go b/cmd/containerbuild/main.go
index 4eeae4c..e99dee5 100644
--- a/cmd/containerbuild/main.go
+++ b/cmd/containerbuild/main.go
@@ -30,14 +30,24 @@ func main() {
koDockerRepo := strings.TrimRight(*dockerRepo, "/"+filepath.Base(*dockerRepo))
version, err := run("git describe --tags --always --dirty")
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ commitTimestamp, err := run("git log -1 --format='%ct'")
+ if err != nil {
+ log.Fatal(err)
+ }
slog.Debug(
"ko env",
"KO_DOCKER_REPO", koDockerRepo,
+ "SOURCE_DATE_EPOCH", commitTimestamp,
"VERSION", version,
)
os.Setenv("KO_DOCKER_REPO", koDockerRepo)
+ os.Setenv("SOURCE_DATE_EPOCH", commitTimestamp)
os.Setenv("VERSION", version)
setOutput("version", version)