feat: version dynamique basée sur Git — build.rs injecte GIT_HASH
CI / lint (push) Failing after 11s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / e2e (push) Has been skipped
CI / security (push) Successful in 15s
Desktop Build / build-windows (push) Has been cancelled
Desktop Build / build-linux (push) Has been cancelled

- build.rs: lit git rev-parse --short HEAD, passe GIT_HASH au compilateur
- main.rs: ABOUT_MSG constant au compile-time avec CARGO_PKG_VERSION + GIT_HASH
- get_version() command Tauri retourne v2.0.0-abc1234
- Log + À propos (menu natif + tray) utilisent la version dynamique
- rerun-if-changed sur .git/HEAD pour recompiler à chaque commit
This commit is contained in:
2026-07-27 17:09:06 -04:00
parent e213ad183e
commit da00aa4826
2 changed files with 36 additions and 7 deletions
+13
View File
@@ -1,3 +1,16 @@
fn main() {
// Inject Git commit hash as version suffix
let git_hash = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output()
.ok()
.and_then(|o| String::from_utf8(o.stdout).ok())
.map(|s| s.trim().to_string())
.unwrap_or_else(|| "unknown".to_string());
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs/heads/main");
tauri_build::build()
}
+23 -7
View File
@@ -238,6 +238,13 @@ fn get_backend_url() -> String {
"http://127.0.0.1:17890".to_string()
}
#[tauri::command]
fn get_version() -> String {
let cargo_version = env!("CARGO_PKG_VERSION");
let git_hash = env!("GIT_HASH");
format!("v{}-{}", cargo_version, git_hash)
}
#[tauri::command]
fn get_config() -> AppConfig {
load_config()
@@ -413,6 +420,15 @@ fn get_window_state() -> AppConfig {
load_config()
}
// Build About message once at compile time
const ABOUT_MSG: &str = concat!(
"ObsiGate Desktop v", env!("CARGO_PKG_VERSION"), "-", env!("GIT_HASH"),
"\\n\\nPorte d\\'entrée native pour vos vaults Obsidian.",
"\\nConstruit avec Tauri + Rust.",
"\\n\\n© Bruno Charest — Licence MIT",
"\\nhttps://git.dracodev.net/Projets/ObsiGate"
);
// ── Entry Point ─────────────────────────────────────────────────────────────
fn main() {
@@ -431,7 +447,8 @@ fn main() {
})
.try_init();
info!("ObsiGate Desktop v2.0.0 starting");
let version_str = format!("v{}-{}", env!("CARGO_PKG_VERSION"), env!("GIT_HASH"));
info!("ObsiGate Desktop {} starting", version_str);
// Resolve exe directory
let exe_dir = std::env::current_exe()
@@ -512,6 +529,7 @@ fn main() {
.manage(backend_state)
.invoke_handler(tauri::generate_handler![
get_backend_url,
get_version,
get_config,
save_vault_path,
get_vault_path,
@@ -730,9 +748,8 @@ fn build_native_menu(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>>
}
"help_about" => {
if let Some(window) = app.get_webview_window("main") {
let _ = window.eval(
r#"alert('ObsiGate Desktop v2.0.0\n\nPorte d\'entrée native pour vos vaults Obsidian.\nConstruit avec Tauri + Rust.\n\n© Bruno Charest — Licence MIT\nhttps://git.dracodev.net/Projets/ObsiGate')"#
);
let js = format!("alert('{}')", ABOUT_MSG);
let _ = window.eval(&js);
}
}
"edit_undo" | "edit_redo" | "edit_cut" | "edit_copy" | "edit_paste" | "edit_select_all" => {
@@ -787,9 +804,8 @@ fn build_tray_menu(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>> {
}
"about" => {
if let Some(window) = app.get_webview_window("main") {
let _ = window.eval(
r#"alert('ObsiGate Desktop v2.0.0\n\nPorte d\'entrée native pour vos vaults Obsidian.\nConstruit avec Tauri + Rust.\n\n© Bruno Charest — Licence MIT\nhttps://git.dracodev.net/Projets/ObsiGate')"#
);
let js = format!("alert('{}')", ABOUT_MSG);
let _ = window.eval(&js);
}
}
_ => {}