Merge pull request #1013 from ludovic111/feat/launcher-beta-builds
🤖 Agent: merged after verify passed, with security-1's dry runs on the branch and an independent review (no regression: parity still runs on every PR from this repo; releases go out unsigned with a warning until the signing key is set).
This commit is contained in:
+63
-4
@@ -31,6 +31,8 @@ pub struct Release {
|
||||
pub body: String,
|
||||
pub date: String,
|
||||
pub asset: Option<(String, u64)>,
|
||||
/// A beta: a game release not promoted to stable yet (a GitHub pre-release, docs/release-flow.md).
|
||||
pub beta: bool,
|
||||
}
|
||||
|
||||
#[cfg(all(target_os = "linux", target_arch = "x86_64"))]
|
||||
@@ -169,6 +171,7 @@ fn parse_releases(
|
||||
.take(10)
|
||||
.collect(),
|
||||
asset: found,
|
||||
beta: r["prerelease"].as_bool().unwrap_or(false),
|
||||
});
|
||||
}
|
||||
out.sort_by(|a, b| compare_versions(&b.tag, &a.tag));
|
||||
@@ -247,6 +250,16 @@ pub fn latest(releases: &[Release]) -> Option<&Release> {
|
||||
releases.iter().find(|r| r.asset.is_some())
|
||||
}
|
||||
|
||||
/// The releases a launcher installs by itself: stable ones, and betas too when the player turned
|
||||
/// "Beta builds" on in Settings.
|
||||
pub fn channel(releases: &[Release], beta: bool) -> Vec<Release> {
|
||||
releases
|
||||
.iter()
|
||||
.filter(|r| beta || !r.beta)
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The community, sponsor and website links, from `launcher/links.json` on main, so they can change
|
||||
/// without a launcher release. An empty address hides its button.
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize)]
|
||||
@@ -1462,10 +1475,17 @@ pub fn launcher_update(releases: &[Release]) -> Option<Release> {
|
||||
pub fn releases_and_updates(
|
||||
on_releases: impl FnOnce(Result<Vec<Release>, String>),
|
||||
) -> Result<Updates, String> {
|
||||
releases_and_updates_with(release_list, installed, launcher_releases_in, on_releases)
|
||||
releases_and_updates_with(
|
||||
Settings::load().beta_builds,
|
||||
release_list,
|
||||
installed,
|
||||
launcher_releases_in,
|
||||
on_releases,
|
||||
)
|
||||
}
|
||||
|
||||
fn releases_and_updates_with(
|
||||
beta: bool,
|
||||
load: impl FnOnce() -> Result<serde_json::Value, String>,
|
||||
installed: impl FnOnce() -> Vec<String>,
|
||||
launchers: impl FnOnce(&serde_json::Value) -> Vec<Release>,
|
||||
@@ -1479,7 +1499,7 @@ fn releases_and_updates_with(
|
||||
}
|
||||
};
|
||||
let releases = parse_releases(&list, ASSET, is_game_tag);
|
||||
let horizon = horizon_update(&releases, &installed());
|
||||
let horizon = horizon_update(&channel(&releases, beta), &installed());
|
||||
on_releases(Ok(releases));
|
||||
Ok(Updates {
|
||||
horizon,
|
||||
@@ -1501,12 +1521,16 @@ pub fn select_after_update(selected: Option<&str>, installed_before: &[String])
|
||||
}
|
||||
}
|
||||
|
||||
/// Installs `tag` (or the newest release with "latest"), then updates the selection as
|
||||
/// Installs `tag` (or with "latest" the newest release of the player's channel), then updates the selection as
|
||||
/// `select_after_update` says when `as_update`, or always selects it otherwise.
|
||||
pub fn install_tag(tag: &str, as_update: bool, progress: impl Fn(f32)) -> Result<String, String> {
|
||||
let releases = releases()?;
|
||||
let release = if tag == "latest" {
|
||||
latest(&releases).ok_or("No release has a build for this platform yet.")?
|
||||
let beta = Settings::load().beta_builds;
|
||||
releases
|
||||
.iter()
|
||||
.find(|r| r.asset.is_some() && (beta || !r.beta))
|
||||
.ok_or("No release has a build for this platform yet.")?
|
||||
} else {
|
||||
releases
|
||||
.iter()
|
||||
@@ -1926,6 +1950,9 @@ pub struct Settings {
|
||||
/// default. Appended after the launcher's own arguments, so they can add to or override them.
|
||||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||||
pub game_args: String,
|
||||
/// Whether new versions include betas (releases not promoted to stable yet). Off by default.
|
||||
#[serde(default)]
|
||||
pub beta_builds: bool,
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
@@ -2117,6 +2144,36 @@ mod tests {
|
||||
assert_eq!(offered(&["v2026.10.15.1", "v2026.10.14"]), None);
|
||||
}
|
||||
|
||||
/// Betas (GitHub pre-releases) install by themselves only with "Beta builds" on; the stable
|
||||
/// channel waits for promote.yml (docs/release-flow.md, "Channels").
|
||||
#[test]
|
||||
fn updates_follow_the_stable_channel_unless_betas_are_on() {
|
||||
let asset = ASSET.unwrap_or("horizon-linux-x86_64.tar.gz");
|
||||
let list = serde_json::json!([
|
||||
{"tag_name": "v2026.10.19.02", "prerelease": true, "assets": [{"name": asset, "browser_download_url": "b", "size": 1}]},
|
||||
{"tag_name": "v2026.10.19.01", "assets": [{"name": asset, "browser_download_url": "s", "size": 1}]},
|
||||
]);
|
||||
let releases = parse_releases(&list, Some(asset), is_game_tag);
|
||||
assert_eq!(
|
||||
releases.iter().map(|r| r.beta).collect::<Vec<_>>(),
|
||||
[true, false]
|
||||
);
|
||||
let offered = |beta: bool, installed: &[&str]| {
|
||||
let installed: Vec<String> = installed.iter().map(|t| t.to_string()).collect();
|
||||
horizon_update(&channel(&releases, beta), &installed).map(|r| r.tag)
|
||||
};
|
||||
assert_eq!(offered(false, &[]), Some("v2026.10.19.01".into()));
|
||||
assert_eq!(
|
||||
offered(true, &["v2026.10.19.01"]),
|
||||
Some("v2026.10.19.02".into())
|
||||
);
|
||||
assert_eq!(offered(false, &["v2026.10.19.01"]), None);
|
||||
// A beta installed earlier is never "updated" to an older stable build.
|
||||
assert_eq!(offered(false, &["v2026.10.19.02"]), None);
|
||||
assert!(!Settings::parse("{}").beta_builds);
|
||||
assert!(Settings::parse(r#"{"beta_builds": true}"#).beta_builds);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_version_is_the_one_the_release_workflow_injects() {
|
||||
assert_eq!(version_or(Some("0.4.2")), "0.4.2");
|
||||
@@ -2135,6 +2192,7 @@ mod tests {
|
||||
body: String::new(),
|
||||
date: String::new(),
|
||||
asset: Some(("u".into(), 1)),
|
||||
beta: false,
|
||||
};
|
||||
assert!(launcher_update(&[r(format!("{LAUNCHER_TAG_PREFIX}{VERSION}"))]).is_none());
|
||||
assert_eq!(
|
||||
@@ -2176,6 +2234,7 @@ mod tests {
|
||||
body: String::new(),
|
||||
date: String::new(),
|
||||
asset: Some(("u".into(), 1)),
|
||||
beta: false,
|
||||
};
|
||||
let releases = [r("v2026.10.13"), r("v2026.10.12")];
|
||||
assert_eq!(
|
||||
|
||||
@@ -45,6 +45,7 @@ fn baseline(load: impl Fn() -> Result<serde_json::Value, String>) -> (Vec<Releas
|
||||
fn shared(load: impl FnOnce() -> Result<serde_json::Value, String>) -> (Vec<Release>, Updates) {
|
||||
let mut releases = None;
|
||||
let updates = releases_and_updates_with(
|
||||
false,
|
||||
load,
|
||||
installed_fixture,
|
||||
|list| parse_releases(list, LAUNCHER_ASSET, is_launcher_tag),
|
||||
@@ -81,6 +82,7 @@ fn errors_reach_releases_and_updates_without_fallback() {
|
||||
] {
|
||||
let mut published = None;
|
||||
let result = releases_and_updates_with(
|
||||
false,
|
||||
|| Err(error.into()),
|
||||
|| panic!("no installed scan after failure"),
|
||||
|_| panic!("no fallback after failure"),
|
||||
@@ -95,6 +97,7 @@ fn errors_reach_releases_and_updates_without_fallback() {
|
||||
fn publish_games_before_older_launcher_fallback() {
|
||||
let events = RefCell::new(Vec::new());
|
||||
let result = releases_and_updates_with(
|
||||
false,
|
||||
|| Ok(serde_json::json!([{"tag_name": "v2026.10.14", "assets": []}])),
|
||||
Vec::new,
|
||||
|list| {
|
||||
@@ -129,6 +132,7 @@ fn failed_launcher_fallback_keeps_game_result_and_checks_stay_fresh() {
|
||||
for day in [14, 15] {
|
||||
let mut published = None;
|
||||
let updates = releases_and_updates_with(
|
||||
false,
|
||||
|| {
|
||||
requests.fetch_add(1, Ordering::Relaxed);
|
||||
Ok(serde_json::json!([{"tag_name": format!("v2026.10.{day}")}]))
|
||||
|
||||
+3
-2
@@ -268,7 +268,7 @@ fn attached(mut cmd: Command) -> Result<(), String> {
|
||||
|
||||
fn release_json(r: &Release) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"tag": r.tag, "name": r.name, "date": r.date,
|
||||
"tag": r.tag, "name": r.name, "date": r.date, "channel": if r.beta { "beta" } else { "stable" },
|
||||
"available_here": r.asset.is_some(), "installed": backend::installed().contains(&r.tag),
|
||||
})
|
||||
}
|
||||
@@ -317,7 +317,8 @@ fn execute(command: Cmd, as_json: bool) -> Result<(), String> {
|
||||
(false, true) => "",
|
||||
(false, false) => "no build for this platform",
|
||||
};
|
||||
println!("{:<14} {} {}", r.tag, r.date, state);
|
||||
let channel = if r.beta { "beta" } else { "stable" };
|
||||
println!("{:<15} {} {:<6} {}", r.tag, r.date, channel, state);
|
||||
}
|
||||
}
|
||||
Cmd::Install { tag } => {
|
||||
|
||||
+27
-8
@@ -1898,6 +1898,15 @@ impl Launcher {
|
||||
cx.notify();
|
||||
}),
|
||||
);
|
||||
let betas = switch("beta-builds", self.settings.beta_builds, &t).on_click(cx.listener(
|
||||
|this, _: &ClickEvent, _, cx| {
|
||||
this.settings.beta_builds = !this.settings.beta_builds;
|
||||
this.settings.save();
|
||||
// What counts as new changed: check again (and install it if that is on).
|
||||
this.check_updates();
|
||||
cx.notify();
|
||||
},
|
||||
));
|
||||
let opening = switch("opening", !self.settings.skip_opening, &t).on_click(cx.listener(
|
||||
|this, _: &ClickEvent, _, cx| {
|
||||
this.settings.skip_opening = !this.settings.skip_opening;
|
||||
@@ -2053,13 +2062,22 @@ impl Launcher {
|
||||
))
|
||||
.child(index_row(
|
||||
n + 2,
|
||||
"Beta builds",
|
||||
Some(plain(
|
||||
"New versions as soon as they are released, before they become stable 6 hours later. Off: only stable versions install by themselves.",
|
||||
)),
|
||||
Some(betas.into_any_element()),
|
||||
&t,
|
||||
))
|
||||
.child(index_row(
|
||||
n + 3,
|
||||
"Show the opening",
|
||||
Some(plain("The wordmark, while the release list loads.")),
|
||||
Some(opening.into_any_element()),
|
||||
&t,
|
||||
))
|
||||
.child(index_row(
|
||||
n + 3,
|
||||
n + 4,
|
||||
"Game menus",
|
||||
Some(plain(
|
||||
"Classic is vanilla's own screens, with no way back inside the game: switch back here. Applies the next time the game starts.",
|
||||
@@ -2067,24 +2085,24 @@ impl Launcher {
|
||||
Some(menus.into_any_element()),
|
||||
&t,
|
||||
))
|
||||
.child(self.game_args_row(n + 4, cx))
|
||||
.child(index_row(n + 5, "Horizon", Some(plain(&horizon)), horizon_action, &t))
|
||||
.child(self.game_args_row(n + 5, cx))
|
||||
.child(index_row(n + 6, "Horizon", Some(plain(&horizon)), horizon_action, &t))
|
||||
.child(index_row(
|
||||
n + 6,
|
||||
n + 7,
|
||||
"Launcher",
|
||||
Some(plain(&launcher)),
|
||||
launcher_action,
|
||||
&t,
|
||||
))
|
||||
.child(index_row(
|
||||
n + 7,
|
||||
n + 8,
|
||||
"Data folder",
|
||||
Some(mono(short(&backend::data_dir()))),
|
||||
None,
|
||||
&t,
|
||||
))
|
||||
.child(index_row(
|
||||
n + 8,
|
||||
n + 9,
|
||||
"Logs",
|
||||
Some(mono(format!(
|
||||
"{} · crash reports beside it",
|
||||
@@ -2103,7 +2121,7 @@ impl Launcher {
|
||||
))
|
||||
.when(cfg!(target_os = "linux"), |d| {
|
||||
d.child(index_row(
|
||||
n + 9,
|
||||
n + 10,
|
||||
"Applications menu",
|
||||
Some(plain(if self.settings.desktop_entry() {
|
||||
"Horizon and its icon are in your desktop's menu."
|
||||
@@ -2603,7 +2621,8 @@ impl Launcher {
|
||||
let tag = release.tag.clone();
|
||||
let installed = self.installed.contains(&tag);
|
||||
let selected = self.selected() == Some(&tag);
|
||||
let mut meta = vec![release.date.clone()];
|
||||
let channel = if release.beta { "Beta" } else { "Stable" };
|
||||
let mut meta = vec![channel.to_string(), release.date.clone()];
|
||||
if let Some((_, size)) = release.asset {
|
||||
meta.push(megabytes(size));
|
||||
}
|
||||
|
||||
+1
-1
@@ -95,7 +95,7 @@ impl Session {
|
||||
{
|
||||
out["releases"] = backend::releases()?
|
||||
.iter()
|
||||
.map(|r| json!({ "tag": r.tag, "name": r.name, "date": r.date, "available_here": r.asset.is_some() }))
|
||||
.map(|r| json!({ "tag": r.tag, "name": r.name, "date": r.date, "channel": if r.beta { "beta" } else { "stable" }, "available_here": r.asset.is_some() }))
|
||||
.collect();
|
||||
}
|
||||
Ok(serde_json::to_string_pretty(&out).unwrap())
|
||||
|
||||
+2
-1
@@ -114,7 +114,8 @@ const parityHeadline = matching === body.length ? "Every subsystem matches vanil
|
||||
|
||||
const isGame = (tag) => /^v\d{4}\.\d{1,2}\.\d{1,2}/.test(tag);
|
||||
const isLauncher = (tag) => tag.startsWith("launcher-v");
|
||||
const game = releases.filter((r) => isGame(r.tag_name)).slice(0, 3);
|
||||
// Stable releases only: betas become stable 6 hours later (docs/release-flow.md, "Channels").
|
||||
const game = releases.filter((r) => isGame(r.tag_name) && !r.prerelease).slice(0, 3);
|
||||
const launcher = releases.find((r) => isLauncher(r.tag_name) && !r.prerelease);
|
||||
|
||||
// --- The page --------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ async function setUpDownload() {
|
||||
const isGame = (tag) => /^v\d{4}\.\d{1,2}\.\d{1,2}/.test(tag);
|
||||
|
||||
async function setUpNotes() {
|
||||
const list = (await releases).filter((r) => isGame(r.tag_name));
|
||||
const list = (await releases).filter((r) => isGame(r.tag_name) && !r.prerelease);
|
||||
if (list.length) document.getElementById("releases").innerHTML = releasesHtml(list.slice(0, 3));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user