Files
wallet/script/stamp-version.sh
rob thijssen 3b7089c8d1
Some checks are pending
ci / gate (push) Waiting to run
ci: a release workflow on a version tag, and bundles named for packaging
Pushing vX.Y.Z runs .gitea/workflows/release.yaml on rust-gtk3: it
refuses a tag that disagrees with the workspace version
(script/stamp-version.sh, which also stamps tauri.conf.json and
ui/package.json from Cargo.toml), builds the webview and the deb, rpm and
AppImage bundles through the npm Tauri CLI, checks the binary answers
--version with the tag, and attaches the bundles, the bare binary and
SHA256SUMS to a Gitea release for the tag using the repository's own
Actions token.

The product is now `blackbeard-wallet`, no space: that name is the
binary, the rpm and deb package, and every release asset, so
`dnf install blackbeard-wallet` reads right. The window title and the
desktop entry keep "blackbeard wallet" through a desktop template. The
binary answers --version and --help before touching the display.

Bundled locally on Fedora 44: deb, rpm (name, license and URL right,
desktop entry installed) and a 114 MB AppImage that prints
"blackbeard-wallet 0.1.0". The AppImage step needs librsvg2-devel for
linuxdeploy's GTK plugin, which the rust-gtk3 runner image does not carry
yet; that is a one-line change in gongfoo, without which the workflow's
bundle step fails on the AppImage.

Refs #32

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014ftBXYuba8ARhQeF74oUgW
2026-09-16 09:10:40 +03:00

32 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Stamp the workspace version into the two files that cannot read it
# themselves: tauri.conf.json (Tauri's CLI wants a literal) and
# ui/package.json. Refuses a tag that disagrees with Cargo.toml, so the
# workspace stays the one source of truth and a release is a tag on it.
#
# script/stamp-version.sh # stamp from Cargo.toml
# script/stamp-version.sh v0.2.0 # also assert the tag matches
set -euo pipefail
here="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
version="$(sed -nE 's/^version = "([^"]+)"$/\1/p' "${here}/Cargo.toml" | head -1)"
[ -n "${version}" ] || { echo "no workspace version in Cargo.toml" >&2; exit 1; }
if [ "${1:-}" != "" ]; then
tag="${1#v}"
if [ "${tag}" != "${version}" ]; then
echo "tag v${tag} does not match the workspace version ${version}; bump Cargo.toml first" >&2
exit 1
fi
fi
python3 - "${version}" "${here}/crates/wallet-app/tauri.conf.json" "${here}/ui/package.json" <<'PY'
import json, sys
version, *files = sys.argv[1:]
for f in files:
with open(f) as fh:
d = json.load(fh)
d["version"] = version
with open(f, "w") as fh:
json.dump(d, fh, indent=2)
fh.write("\n")
print(f"{f}: {version}")
PY