Skip to content

Commit

Permalink
Fetch ui version from Cargo toml
Browse files Browse the repository at this point in the history
  • Loading branch information
trueleo committed Sep 26, 2023
1 parent c3b74c5 commit 5766911
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
}
2 changes: 2 additions & 0 deletions server/src/handlers/http/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ pub async fn about() -> Json<serde_json::Value> {
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,
Expand Down

0 comments on commit 5766911

Please sign in to comment.