From c19f23f42046d68801c6a99fca34308e4985337e Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Fri, 26 Apr 2024 10:38:11 -0400 Subject: [PATCH] build(xtask): bump `build.zig.zon` version when bumping versions --- xtask/src/bump.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/xtask/src/bump.rs b/xtask/src/bump.rs index 94ace796..a4988bcb 100644 --- a/xtask/src/bump.rs +++ b/xtask/src/bump.rs @@ -120,6 +120,7 @@ pub fn bump_versions() -> Result<(), Box> { update_crates(¤t_version, &version)?; update_makefile(&version)?; update_npm(&version)?; + update_zig(&version)?; tag_next_version(&repo, &version)?; Ok(()) @@ -145,6 +146,7 @@ fn tag_next_version( "cli/npm/package.json", "lib/binding_web/package.json", "Makefile", + "build.zig.zon", ] { index.add_path(Path::new(file))?; } @@ -244,6 +246,27 @@ fn update_npm(next_version: &Version) -> Result<(), Box> Ok(()) } +fn update_zig(next_version: &Version) -> Result<(), Box> { + let zig = std::fs::read_to_string("build.zig.zon")?; + + let zig = zig + .lines() + .map(|line| { + if line.starts_with(" .version") { + format!(" .version = \"{next_version}\",") + } else { + line.to_string() + } + }) + .collect::>() + .join("\n") + + "\n"; + + std::fs::write("build.zig.zon", zig)?; + + Ok(()) +} + /// read Cargo.toml and get the version fn fetch_workspace_version() -> Result> { let cargo_toml = toml::from_str::(&std::fs::read_to_string("Cargo.toml")?)?;