Skip to content

Commit

Permalink
feat(dre): allowing self update for macos (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaMilosa authored Jul 17, 2024
1 parent e705306 commit f2559b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ members = [
"rs/np-notifications",
"rs/rollout-controller",
"rs/slack-notifications",
"rs/dre-canisters/trustworthy-node-metrics/src/trustworthy-node-metrics"
"rs/dre-canisters/trustworthy-node-metrics/src/trustworthy-node-metrics",
]

resolver = "2"
Expand Down Expand Up @@ -194,7 +194,7 @@ warp = "0.3"
wiremock = "0.6.0"

# dre-canisters dependencies
ic-cdk-timers = "0.9" # Feel free to remove this dependency if you don't need timers
ic-cdk-timers = "0.9" # Feel free to remove this dependency if you don't need timers
ic-cdk-macros = "0.15.0"
ic-stable-structures = "0.6.5"
ciborium = "0.2.1"
Expand Down
17 changes: 12 additions & 5 deletions rs/cli/src/commands/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,21 @@ impl Upgrade {
return Ok(UpdateStatus::NewVersion(release.version.clone()));
}

// Complete list can be found: https://doc.rust-lang.org/std/env/consts/constant.OS.html
if std::env::consts::OS != "linux" {
return Err(anyhow::anyhow!("Only linux is supported for automatic updates"));
}
let triple = match std::env::consts::OS {
"linux" => "x86_64-unknown-linux",
"macos" => "x86_64-apple-darwin",
s => {
return Err(anyhow::anyhow!(
"{} is not currently not supported for automatic upgrades. Try building the code from source",
s
))
}
};

info!("Binary not up to date. Updating to {}", release.version);
info!("Release: {:?}", release);

let asset = match release.asset_for("dre", None) {
let asset = match release.asset_for(&format!("dre-{}", triple), None) {
Some(asset) => asset,
None => return Err(anyhow::anyhow!("No assets found for release")),
};
Expand Down

0 comments on commit f2559b3

Please sign in to comment.