build: adopt the snap version from Cargo.toml

The version: key in snapcraft.yaml was a second number to bump by
hand, and between releases it read whatever it was left at. The ecrou
part now sets its version from [workspace.package] at pull time —
the same value clap reports with --version — so Cargo.toml is the
only place a version lives, and the release workflow stamps only
that. A missed match fails the pack loudly.
This commit is contained in:
vhaudiquet committed 2026-10-30 16:19:10 +01:00
1 parent a021df7d72
commit 2ac01f992a
2 files changed
+13 -3

No files matched your search

+2 -2
View File
@@ -51,8 +51,8 @@ jobs:
run: | run: |
v="${GITHUB_REF_NAME#v}" v="${GITHUB_REF_NAME#v}"
sed -i "s/^version = \".*\"/version = \"$v\"/" Cargo.toml sed -i "s/^version = \".*\"/version = \"$v\"/" Cargo.toml
sed -i "s/^version: \".*\"/version: \"$v\"/" snap/snapcraft.yaml # The snap adopts this version from Cargo.toml at pull time.
grep -H '^version' Cargo.toml snap/snapcraft.yaml grep -H '^version' Cargo.toml
- uses: snapcore/action-build@v1 - uses: snapcore/action-build@v1
id: build id: build
+11 -1
View File
@@ -1,6 +1,9 @@
name: ecrou name: ecrou
base: core26 base: core26
version: "0.1.0" # The version is adopted from the workspace Cargo.toml at pull time —
# the same value the binary reports with --version. One number, one
# place to bump.
adopt-info: ecrou
title: ecrou title: ecrou
summary: The strictly confined microVM runtime summary: The strictly confined microVM runtime
description: | description: |
@@ -60,6 +63,13 @@ parts:
rust-channel: "1.98.1" rust-channel: "1.98.1"
rust-path: [crates/ecrou-cli] rust-path: [crates/ecrou-cli]
build-packages: [cmake, perl] build-packages: [cmake, perl]
override-pull: |
craftctl default
# [workspace.package] version — the single `version = "..."` at
# the head of the workspace manifest. A missed match fails the
# pack loudly instead of packing a versionless snap.
craftctl set version="$(sed -n 's/^version = "\(.*\)"/\1/p' \
"$CRAFT_PART_SRC/Cargo.toml")"
override-build: | override-build: |
craftctl default craftctl default
# The home interface stops at dotfiles, so ~/.cache is # The home interface stops at dotfiles, so ~/.cache is