2026-03-03 10:46:45 -07:00
|
|
|
#!/usr/bin/env bash
|
2026-03-24 14:53:39 -06:00
|
|
|
# Syncs the version from package.json into all workspace Cargo.toml files,
|
|
|
|
|
# updates Cargo.lock, and regenerates skills.
|
2026-03-03 10:46:45 -07:00
|
|
|
# Used by changesets/action as a custom version command.
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
# Run the standard changeset version command first
|
|
|
|
|
pnpm changeset version
|
|
|
|
|
|
|
|
|
|
# Read the new version from package.json
|
|
|
|
|
VERSION=$(node -p "require('./package.json').version")
|
|
|
|
|
|
2026-03-24 14:53:39 -06:00
|
|
|
# Update version in all workspace crate Cargo.toml files
|
2026-03-03 10:46:45 -07:00
|
|
|
# Uses awk to only change the version under [package], not other sections
|
2026-03-24 14:53:39 -06:00
|
|
|
for cargo_toml in crates/*/Cargo.toml; do
|
|
|
|
|
tmp=$(mktemp)
|
|
|
|
|
awk -v ver="$VERSION" '
|
|
|
|
|
/^\[package\]/ { in_pkg=1 }
|
|
|
|
|
/^\[/ && !/^\[package\]/ { in_pkg=0 }
|
|
|
|
|
in_pkg && /^version = / { $0 = "version = \"" ver "\"" }
|
|
|
|
|
{ print }
|
|
|
|
|
' "$cargo_toml" > "$tmp" && mv "$tmp" "$cargo_toml"
|
|
|
|
|
done
|
2026-03-03 10:46:45 -07:00
|
|
|
|
|
|
|
|
# Update Cargo.lock to match
|
|
|
|
|
cargo generate-lockfile
|
|
|
|
|
|
2026-03-05 00:21:36 -05:00
|
|
|
# Update flake.lock if nix is available
|
|
|
|
|
if command -v nix > /dev/null 2>&1; then
|
|
|
|
|
nix flake lock --update-input nixpkgs
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-24 18:59:55 +01:00
|
|
|
# Regenerate skills so metadata.version tracks the CLI version
|
|
|
|
|
cargo run -- generate-skills --output-dir skills
|
|
|
|
|
|
2026-03-03 10:46:45 -07:00
|
|
|
# Stage the changed files so changesets/action commits them
|
2026-03-24 14:53:39 -06:00
|
|
|
git add crates/*/Cargo.toml Cargo.lock flake.nix flake.lock skills/
|
|
|
|
|
|