-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathbuild.rs
27 lines (25 loc) · 778 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn main() {
let mut ci_tag = String::new();
if let Ok(env) = std::env::var("GOVEE_CI_TAG") {
ci_tag = env.trim().to_string();
} else if let Ok(tag) = std::fs::read(".tag") {
if let Ok(s) = String::from_utf8(tag) {
ci_tag = s.trim().to_string();
}
} else if let Ok(output) = std::process::Command::new("git")
.args(&[
"-c",
"core.abbrev=8",
"show",
"-s",
"--format=%cd-%h",
"--date=format:%Y.%m.%d",
])
.output()
{
let info = String::from_utf8_lossy(&output.stdout);
ci_tag = info.trim().to_string();
}
println!("cargo:rerun-if-changed=.tag");
println!("cargo:rustc-env=GOVEE_CI_TAG={ci_tag}");
}