Skip to content

Commit 1bbdf89

Browse files
authored
fetch console version from Cargo.toml (#518)
If console build is set via environment variable LOCAL_ASSETS_PATH then the version defaults to `development`. It is expected that any client of this API shows the reported version, without any changes.
1 parent c3b74c5 commit 1bbdf89

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static-files = "0.2"
9999
ureq = "2.6"
100100
vergen = { version = "8.1", features = ["build", "git", "cargo", "gitcl"] }
101101
zip = { version = "0.6", default_features = false, features = ["deflate"] }
102+
url = "2.4.0"
102103

103104
[dev-dependencies]
104105
maplit = "1.0"

server/build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ mod ui {
139139
file.write_all(checksum.as_bytes())?;
140140
file.flush()?;
141141

142+
if local_assets_path.is_none() {
143+
// emit ui version for asset url
144+
let url = url::Url::parse(url).expect("valid url");
145+
let ui_version = url
146+
.path_segments()
147+
.expect("has segemnts")
148+
.find(|v| v.starts_with('v'))
149+
.expect("version segement");
150+
println!("cargo:rustc-env=UI_VERSION={}", ui_version);
151+
}
152+
142153
Ok(())
143154
}
144155
}

server/src/handlers/http/about.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ pub async fn about() -> Json<serde_json::Value> {
4444
let store = CONFIG.storage().get_endpoint();
4545
let is_llm_active = &CONFIG.parseable.open_ai_key.is_some();
4646
let llm_provider = is_llm_active.then_some("OpenAI");
47+
let ui_version = option_env!("UI_VERSION").unwrap_or("development");
4748

4849
Json(json!({
4950
"version": current_version,
51+
"uiVersion": ui_version,
5052
"commit": commit,
5153
"deploymentId": deployment_id,
5254
"updateAvailable": update_available,

0 commit comments

Comments
 (0)