feat(server): change semantic versioning to dynamic build date (yyyy.mm.dd)
This commit is contained in:
1 parent
1f050b60b6
commit
44800d4ef2
4 files changed
+115
-1
No files matched your search
@@ -24,3 +24,6 @@ tokio-util = { version = "0.7.19", features = ["io"] }
|
||||
tracing = "0.1.44"
|
||||
tracing-subscriber = "0.3.23"
|
||||
uuid = { version = "1.26.0", features = ["v4"] }
|
||||
|
||||
[build-dependencies]
|
||||
chrono = "0.4.45"
|
||||
@@ -1,6 +1,11 @@
|
||||
use std::process::Command;
|
||||
use chrono::Local;
|
||||
|
||||
fn main() {
|
||||
let now = Local::now();
|
||||
let build_date = now.format("%Y.%m.%d").to_string();
|
||||
println!("cargo:rustc-env=BUILD_DATE={}", build_date);
|
||||
|
||||
if let Ok(output) = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output() {
|
||||
if let Ok(hash) = String::from_utf8(output.stdout) {
|
||||
println!("cargo:rustc-env=GIT_HASH={}", hash.trim());
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ fn run_server(state: Arc<MemoryState>) -> Result<(), Box<dyn std::error::Error>>
|
||||
let app = Router::new()
|
||||
.route("/api/version", get(|| async move {
|
||||
axum::Json(serde_json::json!({
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"version": env!("BUILD_DATE"),
|
||||
"git_hash": option_env!("GIT_HASH").unwrap_or("unknown")
|
||||
}))
|
||||
}))
|
||||
|
||||
Reference in new issue
Block a user