From 5766911789b6a244f6af8567300dcd4090aacaff Mon Sep 17 00:00:00 2001 From: Satyam Singh Date: Tue, 26 Sep 2023 17:37:59 +0530 Subject: [PATCH 1/2] Fetch ui version from Cargo toml --- server/Cargo.toml | 1 + server/build.rs | 11 +++++++++++ server/src/handlers/http/about.rs | 2 ++ 3 files changed, 14 insertions(+) diff --git a/server/Cargo.toml b/server/Cargo.toml index b0a841893..65134510a 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -99,6 +99,7 @@ static-files = "0.2" ureq = "2.6" vergen = { version = "8.1", features = ["build", "git", "cargo", "gitcl"] } zip = { version = "0.6", default_features = false, features = ["deflate"] } +url = "2.4.0" [dev-dependencies] maplit = "1.0" diff --git a/server/build.rs b/server/build.rs index cc60f6ed3..f1c1dc5b2 100644 --- a/server/build.rs +++ b/server/build.rs @@ -139,6 +139,17 @@ mod ui { file.write_all(checksum.as_bytes())?; file.flush()?; + if local_assets_path.is_none() { + // emit ui version for asset url + let url = url::Url::parse(url).expect("valid url"); + let ui_version = url + .path_segments() + .expect("has segemnts") + .find(|v| v.starts_with('v')) + .expect("version segement"); + println!("cargo:rustc-env=UI_VERSION={}", ui_version); + } + Ok(()) } } diff --git a/server/src/handlers/http/about.rs b/server/src/handlers/http/about.rs index 40a0e4d93..1c099f1ca 100644 --- a/server/src/handlers/http/about.rs +++ b/server/src/handlers/http/about.rs @@ -44,9 +44,11 @@ pub async fn about() -> Json { let store = CONFIG.storage().get_endpoint(); let is_llm_active = &CONFIG.parseable.open_ai_key.is_some(); let llm_provider = is_llm_active.then_some("OpenAI"); + let ui_version = option_env!("UI_VERSION"); Json(json!({ "version": current_version, + "uiVersion": ui_version, "commit": commit, "deploymentId": deployment_id, "updateAvailable": update_available, From 60f9ab1c9aab30b2514d8fe664406dd3316481e2 Mon Sep 17 00:00:00 2001 From: Satyam Singh Date: Tue, 26 Sep 2023 20:34:24 +0530 Subject: [PATCH 2/2] Default to development --- server/src/handlers/http/about.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/handlers/http/about.rs b/server/src/handlers/http/about.rs index 1c099f1ca..5ab6ccfba 100644 --- a/server/src/handlers/http/about.rs +++ b/server/src/handlers/http/about.rs @@ -44,7 +44,7 @@ pub async fn about() -> Json { let store = CONFIG.storage().get_endpoint(); let is_llm_active = &CONFIG.parseable.open_ai_key.is_some(); let llm_provider = is_llm_active.then_some("OpenAI"); - let ui_version = option_env!("UI_VERSION"); + let ui_version = option_env!("UI_VERSION").unwrap_or("development"); Json(json!({ "version": current_version,