From 73e3b47ebde706ef66b14ae73c6d8381d50f68e7 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 1 Feb 2026 19:20:21 +1100 Subject: [PATCH] tarball: capture Git version Commit 92dae88f620 (tarball: remove redundant "version" file, 2026-01-12) committed to using Cargo.toml as single source of truth for our version string. This works fine for tarballs built from a tag, but those built from an arbitrary Git commit will show a misleading version ("4.3.3" instead of something like "4.3.3-190-g460081725b5-dirty"). Fix this by copying the Git version to the tarball's Cargo.{toml,lock}. It's not clear if we really need this (it's only for nightly builds) so we might end up reverting this. Ref: https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$BdRagDGCV-8yVjBs0i3QyWUdBK820vTmjuSBqgpsuJY Note that OBS builds are probably still broken from 081c469f6f1 (tarball: include .cargo/config.toml again, 2026-01-13); see https://github.com/fish-shell/fish-shell/pull/12292#discussion_r2694000477 --- build_tools/make_tarball.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/build_tools/make_tarball.sh b/build_tools/make_tarball.sh index 13b044bf0..e4ffceb87 100755 --- a/build_tools/make_tarball.sh +++ b/build_tools/make_tarball.sh @@ -16,11 +16,40 @@ VERSION=$(build_tools/git_version_gen.sh) prefix=fish-$VERSION path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix.tar.xz +tmpdir=$(mktemp -d) +manifest=$tmpdir/Cargo.toml +lockfile=$tmpdir/Cargo.lock + +sed "s/^version = \".*\"\$/version = \"$VERSION\"/g" Cargo.toml \ + >"$manifest" +awk -v version=$VERSION ' + /^name = "fish"$/ { ok=1 } + ok == 1 && /^version = ".*"$/ { + ok = 2; + $0 = "version = \"" version "\""; + } + {print} + ' \ + Cargo.lock >"$lockfile" + +for ext in toml lock; do + if cmp Cargo.$ext "$tmpdir/Cargo.$ext" >/dev/null; then + echo >&2 "failed to update Cargo.$ext version?" + exit 1 + fi +done + git archive \ --prefix="$prefix/" \ + --add-virtual-file="$prefix/Cargo.toml:$(cat "$manifest")" \ + --add-virtual-file="$prefix/Cargo.lock:$(cat "$lockfile")" \ HEAD "$@" | xz >"$path" +rm "$manifest" +rm "$lockfile" +rmdir "$tmpdir" + # Output what we did, and the sha256 hash echo "Tarball written to $path" openssl dgst -sha256 "$path"