feat(updater): switch auto-updater and documentation to Forgejo releases API

This commit is contained in:
katR 2026-10-10 18:11:33 +05:30
parent 6793d6f68f
commit 8652be8b87
4 changed files with 24 additions and 20 deletions

View file

@ -9,12 +9,12 @@ authors = [
"Polyfrost", "Polyfrost",
"Polyfrost Contributors", "Polyfrost Contributors",
] ]
documentation = "https://github.com/oiupoyt/OneLauncher-Cracked" documentation = "https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked"
edition = "2024" edition = "2024"
homepage = "https://polyfrost.org/projects/oneclient" homepage = "https://polyfrost.org/projects/oneclient"
license = "GPL-3.0-only" license = "GPL-3.0-only"
readme = "README.md" readme = "README.md"
repository = "https://github.com/oiupoyt/OneLauncher-Cracked" repository = "https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked"
rust-version = "1.97" rust-version = "1.97"
version = "2.5.1-c3" version = "2.5.1-c3"

View file

@ -6,7 +6,7 @@ forked from [OneLauncher](https://github.com/Polyfrost/OneLauncher) allowing for
</div> </div>
## download from [**Releases Page**](https://github.com/oiupoyt/OneLauncher-Cracked/releases). ## download from [**Releases Page**](https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked/releases).
yes the actual client performs normally aswell yes the actual client performs normally aswell
> [!WARNING] > [!WARNING]

View file

@ -1,7 +1,7 @@
pub const WINDOW_APP_ID: &str = "oneclient_app"; pub const WINDOW_APP_ID: &str = "oneclient_app";
pub const WINDOW_TITLE: &str = "OneClient"; pub const WINDOW_TITLE: &str = "OneClient";
pub const GITHUB_REPO: &str = "oiupoyt/OneLauncher-Cracked"; pub const FORGEJO_REPO: &str = "oiupoyt/OneLauncher-Cracked";
pub const GITHUB_API_LATEST_RELEASE: &str = pub const FORGEJO_API_LATEST_RELEASE: &str =
"https://api.github.com/repos/oiupoyt/OneLauncher-Cracked/releases/latest"; "https://git.oiupoyt.space/api/v1/repos/oiupoyt/OneLauncher-Cracked/releases/latest";
pub const RELEASES_URL: &str = "https://github.com/oiupoyt/OneLauncher-Cracked/releases/latest"; pub const RELEASES_URL: &str = "https://git.oiupoyt.space/oiupoyt/OneLauncher-Cracked/releases";

View file

@ -3,7 +3,7 @@ use std::path::PathBuf;
use oneclient_events::{Choice, EventBus, Prompt}; use oneclient_events::{Choice, EventBus, Prompt};
use uuid::Uuid; use uuid::Uuid;
use crate::constants::GITHUB_API_LATEST_RELEASE; use crate::constants::FORGEJO_API_LATEST_RELEASE;
pub const UPDATE_CHOICE_INSTALL: &str = "update.install"; pub const UPDATE_CHOICE_INSTALL: &str = "update.install";
@ -66,24 +66,28 @@ impl CrackedVersion {
} }
#[derive(Debug, Clone, serde::Deserialize)] #[derive(Debug, Clone, serde::Deserialize)]
pub struct GithubRelease { pub struct ForgejoRelease {
pub tag_name: String, pub tag_name: String,
pub name: Option<String>, pub name: Option<String>,
pub body: Option<String>, pub body: Option<String>,
pub html_url: String, pub html_url: String,
#[serde(default)] #[serde(default)]
pub assets: Vec<GithubReleaseAsset>, pub assets: Vec<ForgejoReleaseAsset>,
} }
pub type GithubRelease = ForgejoRelease;
#[derive(Debug, Clone, serde::Deserialize)] #[derive(Debug, Clone, serde::Deserialize)]
pub struct GithubReleaseAsset { pub struct ForgejoReleaseAsset {
pub name: String, pub name: String,
pub size: u64, pub size: u64,
pub browser_download_url: String, pub browser_download_url: String,
} }
impl GithubRelease { pub type GithubReleaseAsset = ForgejoReleaseAsset;
pub fn find_installer_asset(&self) -> Option<&GithubReleaseAsset> {
impl ForgejoRelease {
pub fn find_installer_asset(&self) -> Option<&ForgejoReleaseAsset> {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
self.assets.iter().find(|a| a.name.ends_with("_x64-setup.exe") || a.name.ends_with("-setup.exe") || a.name.ends_with(".exe")) self.assets.iter().find(|a| a.name.ends_with("_x64-setup.exe") || a.name.ends_with("-setup.exe") || a.name.ends_with(".exe"))
@ -163,7 +167,7 @@ async fn run_simulated_update() -> anyhow::Result<()> {
} }
async fn run_check(auto_install: bool, events: EventBus) -> anyhow::Result<()> { async fn run_check(auto_install: bool, events: EventBus) -> anyhow::Result<()> {
let Some(release) = check_for_github_update().await? else { let Some(release) = check_for_forgejo_update().await? else {
tracing::info!("no update available"); tracing::info!("no update available");
return Ok(()); return Ok(());
}; };
@ -187,7 +191,7 @@ async fn run_check(auto_install: bool, events: EventBus) -> anyhow::Result<()> {
return Ok(()); return Ok(());
} }
download_and_install_github(release, events).await download_and_install_forgejo(release, events).await
} }
fn can_self_update() -> bool { fn can_self_update() -> bool {
@ -215,23 +219,23 @@ fn can_self_update() -> bool {
} }
} }
async fn check_for_github_update() -> anyhow::Result<Option<GithubRelease>> { async fn check_for_forgejo_update() -> anyhow::Result<Option<ForgejoRelease>> {
let client = reqwest::Client::builder() let client = reqwest::Client::builder()
.user_agent("OneLauncher-Cracked-Updater") .user_agent("OneLauncher-Cracked-Updater")
.timeout(std::time::Duration::from_secs(10)) .timeout(std::time::Duration::from_secs(10))
.build()?; .build()?;
let resp = client let resp = client
.get(GITHUB_API_LATEST_RELEASE) .get(FORGEJO_API_LATEST_RELEASE)
.send() .send()
.await?; .await?;
if !resp.status().is_success() { if !resp.status().is_success() {
tracing::debug!("GitHub releases API returned status: {}", resp.status()); tracing::debug!("Forgejo releases API returned status: {}", resp.status());
return Ok(None); return Ok(None);
} }
let release: GithubRelease = resp.json().await?; let release: ForgejoRelease = resp.json().await?;
let current_str = env!("CARGO_PKG_VERSION"); let current_str = env!("CARGO_PKG_VERSION");
let current_ver = CrackedVersion::parse(current_str).unwrap_or(CrackedVersion { let current_ver = CrackedVersion::parse(current_str).unwrap_or(CrackedVersion {
@ -253,7 +257,7 @@ async fn check_for_github_update() -> anyhow::Result<Option<GithubRelease>> {
} }
} }
async fn download_and_install_github(release: GithubRelease, events: EventBus) -> anyhow::Result<()> { async fn download_and_install_forgejo(release: ForgejoRelease, events: EventBus) -> anyhow::Result<()> {
let Some(asset) = release.find_installer_asset() else { let Some(asset) = release.find_installer_asset() else {
events events
.notify("Update available") .notify("Update available")