From 7004a199fca8705c63b3f74eb8c06f457738a160 Mon Sep 17 00:00:00 2001 From: Guillaume Boutry Date: Tue, 16 Jun 2026 14:33:26 +0200 Subject: [PATCH] snap: derive version from git ref Use snapcraft adopt-info to populate the snap version from the static release version and the current git ref at build time. Append +dirty when tracked files differ from HEAD so local builds are visibly not from a clean checkout. Signed-off-by: Guillaume Boutry --- snap/snapcraft.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 3f3358a..93547d3 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,6 @@ name: openstack-hypervisor version: '2026.1' +adopt-info: snap-version base: core26 summary: OpenStack Hypervisor description: | @@ -349,6 +350,21 @@ apps: install-mode: disable parts: + snap-version: + plugin: nil + build-packages: + - git + override-build: | + set -eu + craftctl default + gitref="$(git -C "$CRAFT_PROJECT_DIR" rev-parse --short=8 HEAD)" + version="$(craftctl get version)-${gitref}" + git -C "$CRAFT_PROJECT_DIR" update-index -q --refresh + if ! git -C "$CRAFT_PROJECT_DIR" diff-index --quiet HEAD --; then + version="${version}+dirty" + fi + craftctl set version="${version}" + kvm-support: plugin: nil build-attributes: