fn main() {
let version = std::env::var("PODBOX_VERSION")
.ok()
.filter(|s| !s.is_empty())
.or_else(git_describe)
.unwrap_or_else(|| std::env::var("CARGO_PKG_VERSION").expect("CARGO_PKG_VERSION not set"));
println!("cargo:rustc-env=PODBOX_VERSION={version}");
}
fn git_describe() -> Option<String> {
let output = std::process::Command::new("git")
.args(["describe", "--tags", "--always", "--dirty=-dirty"])
.output()
.ok()?;
if output.status.success() {
String::from_utf8(output.stdout)
.ok()
.map(|s| s.trim().to_string())
} else {
None
}
}