fn bump_crate_version(
    bumped_package: &mut CargoToml<'_>,
    amount: &VersionBump,
    dry_run: bool,
) -> Result<semver::Version> {
    let prev_version = bumped_package.package_version();

    let version = do_version_bump(&prev_version, amount)
        .with_context(|| format!("Failed to bump version of {}", bumped_package.package))?;

    if dry_run {
        log::info!(
            "Dry run: would bump {} version to {version}",
            bumped_package.package,
        );
    } else {
        log::info!("Update {} to {version}", bumped_package.package);
        bumped_package.set_version(&version);
        bumped_package.save()?;
    }

    let package_name = bumped_package.package.to_string();
    for pkg in Package::iter() {
        let mut dependent = CargoToml::new(bumped_package.workspace, pkg)
            .with_context(|| format!("Could not load Cargo.toml of {pkg}"))?;

        if dependent.change_version_of_dependency(&package_name, &version) {
            if dry_run {
                log::info!(
                    "  Dry run: would update {} in {}: ({prev_version} -> {version})",
                    package_name,
                    pkg,
                );
            } else {
                log::info!(
                    "  Bumping {package_name} version for package {pkg}: ({prev_version} -> {version})"
                );
                dependent.save()?;
            }
        }
    }

    Ok(version)
}
Bump the version of the specified package by the specified amount.
xtask/src/commands/release/bump_version.rs