25 lines
693 B
Rust
25 lines
693 B
Rust
use std::process::Command;
|
|
|
|
fn main() {
|
|
let git_hash = Command::new("git")
|
|
.args(["rev-parse", "--short", "HEAD"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|out| String::from_utf8(out.stdout).ok())
|
|
.unwrap_or_else(|| "unknown".to_string());
|
|
|
|
let git_date = Command::new("git")
|
|
.args(["log", "-1", "--format=%cd", "--date=format:%y.%m.%d.%H%M%S"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|out| String::from_utf8(out.stdout).ok())
|
|
.unwrap_or_else(|| "unknown".to_string());
|
|
|
|
let version = format!(
|
|
"{} ({})",
|
|
git_date.trim(),
|
|
git_hash.trim()
|
|
);
|
|
println!("cargo:rustc-env=APP_VERSION={}", version);
|
|
}
|