hex/scripts/set-crate-version.sh
Dax 3434eb5f35
Rename voice-control to hex everywhere, without migrations (#293)
* Rename voice-control to hex everywhere, without migrations

The Cargo package and binary are now hex, every OS keeps its data in a
hex folder, and VOICE_CONTROL_* variables are HEX_*. Hex is a fresh
app: the macOS voice-control rename, its symlink, and the Windows and
Linux beta settings imports are gone. The Windows installer gets a new
AppId so it never takes over an old voice-control install's entry.

* Format

* Drop the Windows paste-last default only the beta import used
2026-10-28 13:08:44 -04:00

31 lines
1.4 KiB
Shell
Executable file

#!/bin/sh
# Stamps the version the release service publishes into Cargo.toml and
# Cargo.lock, so the binaries report it: a dev build's 0.0.0-dev-<run number>
# (as OpenCode numbers its dev builds) or a prerelease X.Y.Z-beta.N of the
# checked-out version. Release builds only; the change is never committed.
#
# set-crate-version.sh <source root> <version>
set -eu
root=$1
version=$2
current=$(sed -n 's/^version = "\([^"]*\)"/\1/p' "$root/Cargo.toml" | head -1)
[ "$version" = "$current" ] && exit 0
printf '%s\n' "$version" | grep -Eq "^(0\.0\.0-dev-[1-9][0-9]*|$(printf '%s' "$current" | sed 's/\./\\./g')-beta\.[0-9]+)\$" || {
echo "Can only stamp 0.0.0-dev-<run> or a $current-beta.N prerelease, not $version." >&2
exit 1
}
# awk, not sed's GNU-only 0,/re/ address: this also runs on the macOS runner.
awk -v current="$current" -v version="$version" '
!done && $0 == "version = \"" current "\"" { $0 = "version = \"" version "\""; done = 1 }
{ print }
' "$root/Cargo.toml" > "$root/Cargo.toml.next"
mv "$root/Cargo.toml.next" "$root/Cargo.toml"
awk -v current="$current" -v version="$version" '
/^name = "hex"$/ { package = 1 }
package && $0 == "version = \"" current "\"" { $0 = "version = \"" version "\""; package = 0 }
{ print }
' "$root/Cargo.lock" > "$root/Cargo.lock.next"
mv "$root/Cargo.lock.next" "$root/Cargo.lock"
grep -q "^version = \"$version\"" "$root/Cargo.toml"
echo "Building Hex as $version." >&2