Files
RhythmWorks/src/modules/updator.rs
T
brotoskyj ff9a46c05c Feature Changes
Added a Token Credential Manager - Closes #4
Added TUI Menu - Closes #2
2026-01-16 10:26:17 -05:00

30 lines
879 B
Rust

use std::thread;
use reqwest;
use semver::Version;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Release {
tag_name: String,
}
pub async fn update() {
let body = reqwest::get(
"https://git.racooncity.org/api/v1/repos/brotoskyj/RhythmWorks/releases/latest",
)
.await
.unwrap()
.text()
.await
.unwrap();
let release_info: Release = serde_json::from_str(&body).unwrap();
let latest_version = Version::parse(&release_info.tag_name).unwrap();
let current_version = Version::parse(env!("CARGO_PKG_VERSION")).unwrap();
if latest_version > current_version {
println!("Update Available! Please download the latest version");
println!("URL: https://git.racooncity.org/brotoskyj/RhythmWorks/releases");
thread::sleep(std::time::Duration::from_secs(10));
std::process::exit(1);
}
}