1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#!/usr/bin/env bash set -euo pipefail if [[ $# -ne 1 ]]; then echo "Usage: s/release <version>" >&2 exit 1 fi version="$1" if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then echo "Invalid version: $version" >&2 exit 1 fi if ! git diff --quiet || ! git diff --cached --quiet; then echo "Working tree is not clean. Commit or stash changes before releasing." >&2 exit 1 fi perl -0pi -e "s/^version = \"[^\"]+\"/version = \"$version\"/m" Cargo.toml git add Cargo.toml git commit -m "Release v$version" git tag "v$version" git push origin HEAD git push origin "v$version" echo "Release v$version pushed. CI will publish artifacts."