From 7b9444ccaa4b811e0fd1aaf2c6820ba9d8ed7cc5 Mon Sep 17 00:00:00 2001 From: Jesse Braham Date: Mon, 11 Nov 2024 16:57:28 +0100 Subject: [PATCH] Modify `bump-version` subcommand to also bump dependent packages' dependencies --- xtask/src/lib.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 043cdda2e77..46fc819dc61 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -433,6 +433,35 @@ pub fn bump_version(workspace: &Path, package: Package, amount: Version) -> Resu manifest["package"]["version"] = toml_edit::value(version.to_string()); fs::write(manifest_path, manifest.to_string())?; + for pkg in Package::iter() { + if [package, Package::HilTest, Package::Examples].contains(&pkg) { + continue; + } + + let manifest_path = workspace.join(pkg.to_string()).join("Cargo.toml"); + let manifest = fs::read_to_string(&manifest_path) + .with_context(|| format!("Could not read {}", manifest_path.display()))?; + + let mut manifest = manifest.parse::()?; + + if manifest["dependencies"] + .as_table() + .unwrap() + .contains_key(&package.to_string()) + { + log::info!( + " Bumping {package} version for package {pkg}: ({prev_version} -> {version})" + ); + + manifest["dependencies"].as_table_mut().map(|table| { + table[&package.to_string()]["version"] = toml_edit::value(version.to_string()) + }); + + fs::write(&manifest_path, manifest.to_string()) + .with_context(|| format!("Could not write {}", manifest_path.display()))?; + } + } + Ok(()) }