|
3 | 3 | //! Subcommands: |
4 | 4 | //! * `bump <patch|minor|major>` — bump the workspace version, refresh |
5 | 5 | //! `Cargo.lock`, mirror to `crates/rakka-accel-py/pyproject.toml`, |
6 | | -//! and rewrite internal-path-dep version pins inside |
7 | | -//! `[workspace.dependencies]`. |
| 6 | +//! rewrite internal-path-dep version pins inside |
| 7 | +//! `[workspace.dependencies]`, and rewrite per-crate inline |
| 8 | +//! `path = "../rakka-accel-*"`-with-`version = "..."` pins so |
| 9 | +//! sibling-crate deps don't drift. |
8 | 10 | //! * `bump --pre <id>` / `bump --set <ver>` — variants for |
9 | 11 | //! pre-release tags and exact-version overrides. |
10 | 12 | //! * `verify` — local mirror of the release-pipeline gate: |
@@ -78,6 +80,7 @@ fn bump(args: Vec<String>) -> Result<()> { |
78 | 80 | println!("{} -> {}", current, next); |
79 | 81 | write_workspace_version(cargo_toml, &next)?; |
80 | 82 | write_workspace_deps_versions(cargo_toml, ¤t, &next)?; |
| 83 | + write_member_inline_deps_versions(¤t, &next)?; |
81 | 84 | if pyproject.exists() { |
82 | 85 | write_pyproject_version(pyproject, &next)?; |
83 | 86 | } |
@@ -214,6 +217,46 @@ fn write_workspace_deps_versions(path: &Path, prev: &str, next: &str) -> Result< |
214 | 217 | Ok(()) |
215 | 218 | } |
216 | 219 |
|
| 220 | +/// Bump every per-crate inline `path = "../rakka-accel-*"`-with-`version = "<prev>"` |
| 221 | +/// pin in member Cargo.tomls. xtask's workspace-deps rewrite covers |
| 222 | +/// `[workspace.dependencies]` only; sibling-crate deps that the |
| 223 | +/// member crates declare directly (e.g. patterns/train/agents/realtime/py |
| 224 | +/// → rakka-accel-cuda) drift on every bump otherwise, breaking |
| 225 | +/// `cargo publish` with "no matching package" errors. |
| 226 | +fn write_member_inline_deps_versions(prev: &str, next: &str) -> Result<()> { |
| 227 | + let crates_dir = Path::new("crates"); |
| 228 | + if !crates_dir.exists() { |
| 229 | + return Ok(()); |
| 230 | + } |
| 231 | + let needle = format!("version = \"{prev}\""); |
| 232 | + let replacement = format!("version = \"{next}\""); |
| 233 | + for entry in std::fs::read_dir(crates_dir)? { |
| 234 | + let entry = entry?; |
| 235 | + let manifest = entry.path().join("Cargo.toml"); |
| 236 | + if !manifest.exists() { |
| 237 | + continue; |
| 238 | + } |
| 239 | + let text = std::fs::read_to_string(&manifest)?; |
| 240 | + let mut out = String::with_capacity(text.len()); |
| 241 | + let mut changed = false; |
| 242 | + for line in text.split_inclusive('\n') { |
| 243 | + // Only rewrite lines that pin a sibling rakka-accel-* path |
| 244 | + // dep at the previous workspace version. |
| 245 | + let is_sibling_path = line.contains("path = \"../rakka-accel"); |
| 246 | + if is_sibling_path && line.contains(&needle) { |
| 247 | + out.push_str(&line.replace(&needle, &replacement)); |
| 248 | + changed = true; |
| 249 | + } else { |
| 250 | + out.push_str(line); |
| 251 | + } |
| 252 | + } |
| 253 | + if changed { |
| 254 | + std::fs::write(&manifest, out)?; |
| 255 | + } |
| 256 | + } |
| 257 | + Ok(()) |
| 258 | +} |
| 259 | + |
217 | 260 | fn write_pyproject_version(path: &Path, version: &str) -> Result<()> { |
218 | 261 | // pyproject.toml in maturin mode declares `dynamic = ["version"]` |
219 | 262 | // — the wheel version comes from Cargo.toml. We still update the |
|
0 commit comments