From 81024ecc22cb6fd44023745896d125b74f599409 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 25 Jan 2026 11:53:27 +1100 Subject: [PATCH] feat: replace date tag with git commit SHA and add version tag Replace date-based Docker tags with git commit SHA and version from version file. This improves traceability by linking images to specific commits and versions. --- Makefile | 1 + builds/docker.pkr.hcl | 2 +- library/variables.pkr.hcl | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 01c934c..88be688 100644 --- a/Makefile +++ b/Makefile @@ -81,6 +81,7 @@ $(DIRS): # Build the image @(cd $(IMAGES_PATH)/$@ && \ export DATE=$(DATE_TAG) && \ + export VERSION=$$(cat version) && \ export OS_NAME=$$(echo $@ | cut -d'/' -f1) && \ export OS_VERSION_FULL=$$(echo $@ | cut -d'/' -f2) && \ export OS_IMAGE=$$(echo $@ | cut -d'/' -f3) && \ diff --git a/builds/docker.pkr.hcl b/builds/docker.pkr.hcl index 3a3f79e..b678371 100644 --- a/builds/docker.pkr.hcl +++ b/builds/docker.pkr.hcl @@ -64,7 +64,7 @@ build { post-processors { post-processor "docker-tag" { repository = "${var.docker_server}/unkin/${var.os_name}${var.os_version_major}-${var.os_image}" - tags = ["latest", var.date] + tags = ["latest", var.git_commit, var.version] } dynamic "post-processor" { diff --git a/library/variables.pkr.hcl b/library/variables.pkr.hcl index 2a08131..a56acdb 100644 --- a/library/variables.pkr.hcl +++ b/library/variables.pkr.hcl @@ -121,6 +121,11 @@ variable "git_branch" { type = string default = env("GIT_BRANCH") } +variable "version" { + description = "The version from version file." + type = string + default = env("VERSION") +} variable "include_incus_client_certs" { type = bool default = false