feat: add COMMIT_HASH build time env var
This commit is contained in:
parent
e7d06a45f6
commit
3b7e976deb
3 changed files with 22 additions and 0 deletions
17
build.rs
Normal file
17
build.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let commit_hash = match std::env::var("COMMIT_HASH") {
|
||||||
|
Ok(commit_hash_string) => commit_hash_string,
|
||||||
|
Err(_) => {
|
||||||
|
match Command::new("git")
|
||||||
|
.args(vec!["rev-parse", "--short", "HEAD"])
|
||||||
|
.output()
|
||||||
|
{
|
||||||
|
Ok(x) => String::from_utf8_lossy(x.stdout.trim_ascii_end()).into_owned(),
|
||||||
|
Err(_) => "no hash :(".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
println!("cargo::rustc-env=COMMIT_HASH=\"{}\"", commit_hash);
|
||||||
|
}
|
||||||
|
|
@ -44,6 +44,9 @@
|
||||||
|
|
||||||
# Additional environment variables can be set directly
|
# Additional environment variables can be set directly
|
||||||
# MY_CUSTOM_VAR = "some value";
|
# MY_CUSTOM_VAR = "some value";
|
||||||
|
COMMIT_HASH = builtins.substring 0 7 (
|
||||||
|
if self ? rev then self.rev else "nixDirt"
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
craneLibLLvmTools = craneLib.overrideToolchain
|
craneLibLLvmTools = craneLib.overrideToolchain
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ async fn main() {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt::init();
|
||||||
let cache = KubeCache::Cache::create().unwrap();
|
let cache = KubeCache::Cache::create().unwrap();
|
||||||
let arcCache = Arc::new(cache);
|
let arcCache = Arc::new(cache);
|
||||||
|
let commit_hash: &'static str = env!("COMMIT_HASH");
|
||||||
|
println!("COMMIT_HASH: {}", commit_hash);
|
||||||
|
|
||||||
let mut listener = TcpListener::bind("0.0.0.0:25565").await.unwrap();
|
let mut listener = TcpListener::bind("0.0.0.0:25565").await.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue