Use commit for version again
All checks were successful
Gitea Organization/dotfiles/pipeline/pr-installer This commit looks good

This commit is contained in:
2023-02-12 23:30:26 +01:00
parent cb8ef1e2e8
commit 60fce326dd
5 changed files with 10 additions and 11 deletions

View File

@@ -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 {

View File

@@ -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");