feat: add build version with timestamp

- Add build.rs to generate BUILD_VERSION at compile time
- Update CLI to show full version: '0.1.0 (build: 2026-03-31 11:21:37)'
- Update health endpoints to return build version
- Add chrono as build dependency
This commit is contained in:
Warren
2026-03-31 11:30:50 +08:00
parent 37d2b66c56
commit 576f58df71
5 changed files with 152 additions and 10 deletions

19
build.rs Normal file
View File

@@ -0,0 +1,19 @@
use chrono::Local;
use std::env;
fn main() {
let now = Local::now();
let build_time = now.format("%Y-%m-%d %H:%M:%S").to_string();
// Get version from Cargo.toml
let version = env!("CARGO_PKG_VERSION");
let full_version = format!("{} (build: {})", version, build_time);
// Set build-time environment variables
println!("cargo:rustc-env=BUILD_VERSION={}", full_version);
println!("cargo:rustc-env=BUILD_TIME={}", build_time);
println!("cargo:rustc-env=VERSION={}", version);
// Also print for debugging
println!("cargo:warning=Building version: {}", full_version);
}