Use commit for version again
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good
This commit is contained in:
@@ -29,7 +29,7 @@ impl ToString for MainMenu {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if let Some(version) = option_env!("BUILD_NUMBER") {
|
||||
if let Some(version) = option_env!("GIT_COMMIT") {
|
||||
println!("Starting installer version {}", version);
|
||||
update::check_for_updates(version);
|
||||
} else {
|
||||
|
||||
@@ -10,19 +10,16 @@ struct PackageEntry {
|
||||
version: String
|
||||
}
|
||||
|
||||
const GITEA_KEY: &str = "1e9527c38c98b297dbdaaf39c060e075b2729464";
|
||||
const GITEA_KEY: &str = "786666bd8bce93c562c4fc4c83933faa6cbdc802";
|
||||
|
||||
pub fn check_for_updates(version: &str) {
|
||||
let version: u64 = version.parse().unwrap();
|
||||
print!("Checking for updates... ");
|
||||
let resp: Vec<PackageEntry> = attohttpc::get("https://gitea.mattv.de/api/v1/packages/root?type=generic&q=installer")
|
||||
let resp: serde_json::Value = attohttpc::get("https://gitea.mattv.de/api/v1/repos/root/dotfiles/branches/installer")
|
||||
.header("accept", "application/json")
|
||||
.header("Authorization", format!("token {GITEA_KEY}"))
|
||||
.send().unwrap().json().unwrap();
|
||||
let newest = resp.into_iter()
|
||||
.map(|entry| entry.version.parse::<u64>().unwrap())
|
||||
.max().unwrap();
|
||||
if newest > version {
|
||||
let newest = resp["commit"]["id"].as_str().unwrap();
|
||||
if newest != version {
|
||||
println!("New version {newest}");
|
||||
let exe = current_exe().unwrap();
|
||||
let temp = Path::new("temp");
|
||||
|
||||
Reference in New Issue
Block a user