VERSION (racine) devient la source unique de verite MAJEUR.MINEUR.CORRECTIF, incrementee a chaque commit par le hook prepare-commit-msg (BREAKING -> majeur, feat -> mineur, sinon correctif) ; post-commit rattache les fichiers derives au commit et cree le tag vX.Y.Z, publie au push (push.followTags). Tous les derives sont resynchronises : package.json, desktop Tauri, README.md/README.fr.md, docs/ROADMAP.md, CHANGELOG.md. Backend, image Docker et desktop lisent le meme fichier (plus de numero code en dur). Outils : scripts/bump_version.py, scripts/install-hooks.sh. Tests : tests/test_version.py (46, garde-fou de coherence globale).
43 lines
1.6 KiB
Rust
43 lines
1.6 KiB
Rust
fn main() {
|
|
// Version livrée : `VERSION` (racine du dépôt) est la source unique de
|
|
// vérité (même fichier que backend/version.py et l'image Docker).
|
|
// Repli : `git describe` quand le fichier n'est pas dans le contexte de build.
|
|
let version = std::fs::read_to_string(
|
|
std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../VERSION"),
|
|
)
|
|
.ok()
|
|
.map(|s| s.trim().to_string())
|
|
.filter(|s| !s.is_empty())
|
|
.unwrap_or_else(|| {
|
|
std::process::Command::new("git")
|
|
.args(["describe", "--tags", "--dirty=-dirty"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| String::from_utf8(o.stdout).ok())
|
|
.map(|s| s.trim().trim_start_matches('v').to_string())
|
|
.unwrap_or_else(|| "0.0.0".to_string())
|
|
});
|
|
|
|
// Extract short hash for display
|
|
let short_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());
|
|
|
|
// SemVer base (strip -suffix)
|
|
let semver_base = version.split('-').next().unwrap_or("0.0.0");
|
|
|
|
println!("cargo:rustc-env=GIT_VERSION={}", version);
|
|
println!("cargo:rustc-env=GIT_HASH={}", short_hash);
|
|
println!("cargo:rustc-env=SEMVER={}", semver_base);
|
|
println!("cargo:rerun-if-changed=../VERSION");
|
|
println!("cargo:rerun-if-changed=.git/HEAD");
|
|
println!("cargo:rerun-if-changed=.git/refs/heads/main");
|
|
println!("cargo:rerun-if-changed=.git/refs/tags");
|
|
|
|
tauri_build::build()
|
|
}
|