gitlab/
gitlab.rs

1/*!
2Example updating an executable to the latest version released via Gitlab
3*/
4
5// For the `cargo_crate_version!` macro
6#[macro_use]
7extern crate self_update;
8
9fn run() -> Result<(), Box<dyn ::std::error::Error>> {
10    let releases = self_update::backends::gitlab::ReleaseList::configure()
11        .repo_owner("jaemk")
12        .repo_name("self_update")
13        .build()?
14        .fetch()?;
15    println!("found releases:");
16    println!("{:#?}\n", releases);
17
18    let status = self_update::backends::gitlab::Update::configure()
19        .repo_owner("jaemk")
20        .repo_name("self_update")
21        .bin_name("github")
22        .show_download_progress(true)
23        //.target_version_tag("v9.9.10")
24        //.show_output(false)
25        //.no_confirm(true)
26        //
27        // For private repos, you will need to provide an auth token
28        // **Make sure not to bake the token into your app**; it is recommended
29        // you obtain it via another mechanism, such as environment variables
30        // or prompting the user for input
31        //.auth_token(env!("DOWNLOAD_AUTH_TOKEN"))
32        .current_version(cargo_crate_version!())
33        .build()?
34        .update()?;
35    println!("Update status: `{}`!", status.version());
36    Ok(())
37}
38
39pub fn main() {
40    if let Err(e) = run() {
41        println!("[ERROR] {}", e);
42        ::std::process::exit(1);
43    }
44}