Skip to content

Commit a2ad931

Browse files
committed
Replace OpenSSL release check dependency
1 parent d1e597e commit a2ad931

13 files changed

Lines changed: 86 additions & 493 deletions

File tree

‎Cargo.lock‎

Lines changed: 41 additions & 447 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ ab_glyph = "0.2"
108108
icy_ui = { git = "https://github.com/mkrueger/icy_ui", branch = "master" }
109109

110110
versions = "7.0.0"
111-
github_release_check = "0.2.1"
112111
parking_lot = "0.12.5"
113112
clap-i18n-richformatter = { git = "https://github.com/eatradish/clap-i18n-richformatter" }
114113

‎crates/icy_draw/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ flexi_logger = { workspace = true }
3131
# CLI
3232
clap = { workspace = true }
3333
clap-i18n-richformatter = { workspace = true }
34-
github_release_check = { workspace = true }
3534

3635
# Core icy_* crates
3736
icy_engine = { workspace = true }

‎crates/icy_draw/src/main.rs‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,7 @@ pub static PENDING_NEW_WINDOW_BUFFERS: std::sync::LazyLock<std::sync::Mutex<Vec<
7979

8080
/// Latest version available on GitHub (checked at startup)
8181
pub static LATEST_VERSION: std::sync::LazyLock<Version> = std::sync::LazyLock::new(|| {
82-
let github = github_release_check::GitHub::new().unwrap();
83-
if let Ok(ver) = github.get_all_versions("mkrueger/icy_tools") {
84-
for v in ver {
85-
if let Some(rest) = v.strip_prefix("IcyDraw") {
86-
if let Ok(parsed) = Version::parse(rest) {
87-
return parsed;
88-
}
89-
}
90-
}
91-
}
92-
VERSION.clone()
82+
icy_engine_gui::release_check::latest_release("mkrueger/icy_tools", "IcyDraw").unwrap_or_else(|| VERSION.clone())
9383
});
9484

9585
#[derive(rust_embed::RustEmbed)]

‎crates/icy_engine_gui/Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ rodio = { workspace = true }
4747
tokio = { workspace = true, features = ["rt", "time", "sync"] }
4848
semver = { workspace = true }
4949

50+
# GitHub release check for the "update available" banners
51+
reqwest = { workspace = true, features = ["json"] }
52+
5053
# File dialog
5154
rfd = { workspace = true }
5255

‎crates/icy_engine_gui/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ pub mod util;
8383

8484
pub mod music;
8585

86+
pub mod release_check;
87+
8688
//pub mod terminal_shader_widget;
8789

8890
use serde::{Deserialize, Serialize};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::time::Duration;
2+
3+
use semver::Version;
4+
use serde::Deserialize;
5+
6+
const REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
7+
8+
#[derive(Deserialize)]
9+
struct Release {
10+
tag_name: String,
11+
}
12+
13+
/// Newest published release whose tag starts with `tag_prefix`, e.g. `("mkrueger/icy_tools", "IcyTerm")`.
14+
///
15+
/// Returns `None` on any network or parse failure so callers fall back to their own version.
16+
pub fn latest_release(repo: &str, tag_prefix: &str) -> Option<Version> {
17+
let response = reqwest::blocking::Client::builder()
18+
.timeout(REQUEST_TIMEOUT)
19+
.user_agent(concat!("icy_tools/", env!("CARGO_PKG_VERSION")))
20+
.build()
21+
.ok()?
22+
.get(format!("https://api.github.com/repos/{repo}/releases?per_page=100"))
23+
.header("Accept", "application/vnd.github+json")
24+
.send()
25+
.ok()?
26+
.error_for_status()
27+
.ok()?;
28+
29+
// GitHub lists releases newest first, so the first prefix match is the latest.
30+
response
31+
.json::<Vec<Release>>()
32+
.ok()?
33+
.into_iter()
34+
.find_map(|release| release.tag_name.strip_prefix(tag_prefix).and_then(|version| Version::parse(version).ok()))
35+
}

‎crates/icy_mail/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ tokio = { workspace = true }
1717
serde = { workspace = true }
1818
versions = { workspace = true }
1919
regex = { workspace = true }
20-
github_release_check = { workspace = true }
2120
semver = { workspace = true }
2221
webbrowser = { workspace = true }
2322
icy_engine_gui = { workspace = true }

‎crates/icy_mail/src/main.rs‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,7 @@ static START_TIME: LazyLock<Instant> = LazyLock::new(Instant::now);
5252

5353
#[allow(dead_code)] // reserved for a future update-check UI; previously hidden from dead_code analysis by the lazy_static macro
5454
static LATEST_VERSION: LazyLock<Version> = LazyLock::new(|| {
55-
let github = github_release_check::GitHub::new().unwrap();
56-
if let Ok(ver) = github.get_all_versions("mkrueger/icy_tools") {
57-
for v in ver {
58-
if let Some(rest) = v.strip_prefix("IcyMail") {
59-
return Version::parse(rest).unwrap();
60-
}
61-
}
62-
}
63-
VERSION.clone()
55+
icy_engine_gui::release_check::latest_release("mkrueger/icy_tools", "IcyMail").unwrap_or_else(|| VERSION.clone())
6456
});
6557
/*
6658
#[derive(rust_embed::RustEmbed)]

‎crates/icy_term/Cargo.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ tokio = { workspace = true }
2121
serde = { workspace = true }
2222
versions = { workspace = true }
2323
regex = { workspace = true }
24-
github_release_check = { workspace = true }
2524
semver = { workspace = true }
2625
webbrowser = { workspace = true }
2726
icy_engine_gui = { workspace = true }

0 commit comments

Comments
 (0)