Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Add auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
GeckoEidechse committed Jul 31, 2022
1 parent a64ac12 commit 440fd01
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 12 deletions.
123 changes: 114 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ serde = { version = "1", features = ["derive"] } # You only need this if you wan
serde_json = "1.0.81"
reqwest = { version = "0.11", features = ["blocking"] }
zip = "0.6.2"
self_update = "0.30.0"

# native:
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
8 changes: 5 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use core::time;

use self::util::apply_mods_pr;
use self_update::cargo_crate_version;

mod util;

const VERSION: &str = env!("CARGO_PKG_VERSION");

/// We derive Deserialize/Serialize so we can persist app state on shutdown.
#[derive(serde::Deserialize, serde::Serialize)]
#[serde(default)] // if we add new fields, give them default values when deserializing old state
Expand Down Expand Up @@ -109,7 +108,10 @@ impl eframe::App for TemplateApp {
egui::CentralPanel::default().show(ctx, |ui| {
// The central panel the region left after adding TopPanel's and SidePanel's

ui.heading(format!("Northstar dev testing helper tool (v{})", VERSION));
ui.heading(format!(
"Northstar dev testing helper tool (v{})",
cargo_crate_version!()
));
ui.add(egui::github_link_file!(
"https://github.com/GeckoEidechse/northstar_dev_testing_helper_tool",
"Source code."
Expand Down
19 changes: 19 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#![warn(clippy::all, rust_2018_idioms)]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use self_update::cargo_crate_version;

pub fn do_self_update() -> Result<(), Box<dyn ::std::error::Error>> {
let status = self_update::backends::github::Update::configure()
.repo_owner("GeckoEidechse")
.repo_name("northstar_dev_testing_helper_tool")
.bin_name("github") // <-- name of the binary in the zip to use to replcae current version with
.show_download_progress(true)
.current_version(cargo_crate_version!())
.build()?
.update()?;
println!("Update status: `{}`!", status.version());
Ok(())
}

fn main() {
// Log to stdout (if you run with `RUST_LOG=debug`).
tracing_subscriber::fmt::init();

if do_self_update().is_err() {
println!("Failed fetching update!");
}

let native_options = eframe::NativeOptions::default();
eframe::run_native(
"eframe template",
Expand Down

0 comments on commit 440fd01

Please sign in to comment.