2020-07-16 19:32:30 +00:00
|
|
|
use ructe::{Result, Ructe};
|
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
Ructe::from_env()?.compile_templates("templates")?;
|
|
|
|
|
2021-01-02 23:11:18 +00:00
|
|
|
let output = Command::new("git")
|
|
|
|
.args(&["rev-parse", "HEAD"])
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
2021-01-09 22:16:30 +00:00
|
|
|
|
2021-03-04 04:37:47 +00:00
|
|
|
let out = std::env::var("out").unwrap_or("/fake".into());
|
|
|
|
println!("cargo:rustc-env=out={}", out);
|
2021-01-09 22:16:30 +00:00
|
|
|
|
2020-07-16 19:32:30 +00:00
|
|
|
let git_hash = String::from_utf8(output.stdout).unwrap();
|
2021-01-03 16:42:09 +00:00
|
|
|
println!(
|
|
|
|
"cargo:rustc-env=GITHUB_SHA={}",
|
|
|
|
if git_hash.as_str() == "" {
|
2021-03-04 04:37:47 +00:00
|
|
|
out.into()
|
2021-01-03 16:42:09 +00:00
|
|
|
} else {
|
|
|
|
git_hash
|
|
|
|
}
|
|
|
|
);
|
2020-07-16 19:32:30 +00:00
|
|
|
Ok(())
|
|
|
|
}
|