#!/usr/bin/env bash # # Set the version in every file that declares one. # # There are four, and they must agree: a mismatch means a published release # looks older than what is installed, so the update either never offers or # offers forever. This exists because a line-numbered `sed` edited the wrong # line after a new crate shifted Cargo.toml down by one, and only the # version-drift test noticed. set -euo pipefail [ $# -eq 1 ] || { echo "usage: $0 " >&2; exit 1; } NEW="$1" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Matched by content and by section, never by line number. python3 - "$ROOT" "$NEW" <<'PY' import re, sys, json, pathlib root, new = pathlib.Path(sys.argv[1]), sys.argv[2] def sub_toml(path, count=1): p = root / path s = p.read_text() s2, n = re.subn(r'(?m)^version = "\d+\.\d+\.\d+"$', f'version = "{new}"', s, count=count) assert n == count, f"{path}: expected {count} version line(s), changed {n}" p.write_text(s2) def sub_json(path): p = root / path s = p.read_text() s2, n = re.subn(r'"version":\s*"\d+\.\d+\.\d+"', f'"version": "{new}"', s, count=1) assert n == 1, f"{path}: no version field" json.loads(s2) # refuse to write invalid JSON p.write_text(s2) sub_toml("Cargo.toml") sub_toml("gui/src-tauri/Cargo.toml") sub_json("gui/src-tauri/tauri.conf.json") sub_json("gui/package.json") print(f" version set to {new} in 4 files") PY