#!/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 # The workspace's own crates pin each other exactly; keep the pins on the # workspace version, or a bump leaves Cargo.lock unresolvable. sed -i -E "s/^(wallet-[a-z]+ = \{ path = \"crates\/wallet-[a-z]+\", version = \")=[^\"]+(\" \})/\1=${version}\2/" "${here}/Cargo.toml" 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