mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 18:20:30 +08:00
radicle-tauri/build: Allow Specifying Version via GIT_HEAD
This now allows setting `GIT_HEAD` "from the outside" and will gracefully fall back to "unknown" in case there's any issue figuring out what HEAD refers to.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
use std::env;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
.output()
|
||||
.expect("failed to execute git");
|
||||
let git_head = String::from_utf8(output.stdout).unwrap();
|
||||
println!("cargo:rustc-env=GIT_HEAD={}", git_head);
|
||||
let head = env::var("GIT_HEAD").unwrap_or_else(|_| {
|
||||
Command::new("git")
|
||||
.args(["rev-parse", "--short", "HEAD"])
|
||||
.output()
|
||||
.map(|output| String::from_utf8(output.stdout).expect("output from Git is UTF-8"))
|
||||
.unwrap_or("unknown".into())
|
||||
});
|
||||
println!("cargo::rustc-env=GIT_HEAD={head}");
|
||||
|
||||
tauri_build::build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user