Switched self-updater to packages, stop creating releases
This commit is contained in:
		@@ -6,37 +6,27 @@ use std::path::Path;
 | 
			
		||||
use serde::Deserialize;
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
struct Commit {
 | 
			
		||||
    id: String
 | 
			
		||||
struct Pipeline {
 | 
			
		||||
    sha: String
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
struct Link {
 | 
			
		||||
    direct_asset_url: String
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
struct Assets {
 | 
			
		||||
    links: Vec<Link>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Deserialize)]
 | 
			
		||||
struct ReleaseEntry {
 | 
			
		||||
    commit: Commit,
 | 
			
		||||
    assets: Assets
 | 
			
		||||
struct PackageEntry {
 | 
			
		||||
    version: String,
 | 
			
		||||
    pipeline: Pipeline
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn check_for_updates(version: &str) {
 | 
			
		||||
    print!("Checking for updates... ");
 | 
			
		||||
    let resp: Vec<ReleaseEntry> = attohttpc::get("https://gitlab.mattv.de/api/v4/projects/43/releases").send().unwrap().json().unwrap();
 | 
			
		||||
    let resp: Vec<PackageEntry> = attohttpc::get("https://gitlab.mattv.de/api/v4/projects/43/packages?name=installer&sort=desc").send().unwrap().json().unwrap();
 | 
			
		||||
    let newest = resp.first().unwrap();
 | 
			
		||||
    if newest.commit.id != version {
 | 
			
		||||
    if newest.pipeline.sha != version {
 | 
			
		||||
        println!("New version exists");
 | 
			
		||||
        let exe = current_exe().unwrap();
 | 
			
		||||
        let temp = Path::new("temp");
 | 
			
		||||
 | 
			
		||||
        print!("Downloading... ");
 | 
			
		||||
        attohttpc::get(newest.assets.links.first().unwrap().direct_asset_url.clone()).send().unwrap().write_to(File::create(temp).unwrap()).unwrap();
 | 
			
		||||
        attohttpc::get(format!("https://gitlab.mattv.de/api/v4/projects/43/packages/generic/installer/{}/installer-amd64", newest.version)).send().unwrap().write_to(File::create(temp).unwrap()).unwrap();
 | 
			
		||||
        println!("Done");
 | 
			
		||||
 | 
			
		||||
        fs::set_permissions(&temp, exe.metadata().unwrap().permissions()).unwrap();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user