seperate into multiple source files

This commit is contained in:
2023-08-29 06:47:40 +02:00
parent ced346f776
commit 63f160ff4a
6 changed files with 187 additions and 144 deletions

25
src/github.rs Normal file
View File

@@ -0,0 +1,25 @@
use crate::global::*;
use semver::Version;
pub fn latest_version() -> Version {
let github_body = crate::http::get_body_string(
format!(
"https://api.github.com/repos/{}/{}/releases/latest",
GH_OWNER, GH_REPO
)
.as_str(),
);
let github_json: serde_json::Value = serde_json::from_str(&github_body).unwrap();
let latest_version = github_json["tag_name"]
.to_string()
.replace(['v', '"'].as_ref(), "");
Version::parse(&latest_version).unwrap()
}
pub fn latest_release_url() -> String {
format!(
"https://github.com/{}/{}/releases/latest",
GH_OWNER, GH_REPO
)
}