Merge pull request #1131 from ludovic111/feat/version-sources
🤖 Agent: merged after integration wave 1 on the desktop (main e730dc14 + #1108 #1114 #1131 #1157 #1158 #1162 = ae482a72): fmt, clippy -D warnings, workspace tests (one port-race flake in horizon-server panel, passes on rerun), release build, tools/parity.py --changed origin/main 299/302 then the 3 rerun: save_roundtrip pass, world_reopen pass x2 (one early-count flake), dedicated_server = known flake also failing on main (fixed by #1183/#1184).
This commit is contained in:
@@ -45,6 +45,7 @@ jobs:
|
||||
outputs:
|
||||
release: ${{ steps.decide.outputs.release }}
|
||||
tag: ${{ steps.decide.outputs.tag }}
|
||||
version: ${{ steps.decide.outputs.version }}
|
||||
head: ${{ steps.decide.outputs.head }}
|
||||
dry_run: ${{ steps.mode.outputs.dry_run }}
|
||||
steps:
|
||||
@@ -65,6 +66,9 @@ jobs:
|
||||
run: |
|
||||
python3 tools/release_train.py decide --kind game ${HEAD_SHA:+--head "$HEAD_SHA"} ${FORCE:+--force} | tee decision.json
|
||||
echo "### $(jq -r '.reason' decision.json)" >> "$GITHUB_STEP_SUMMARY"
|
||||
# The version the programs are built with (docs/versioning.md): the tag without its v.
|
||||
tag=$(jq -r '.tag' decision.json)
|
||||
echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
|
||||
# A dry run builds whatever the decision, to test the builds.
|
||||
if [[ "${{ steps.mode.outputs.dry_run }}" == true ]]; then echo "release=true" >> "$GITHUB_OUTPUT"; fi
|
||||
|
||||
@@ -99,6 +103,9 @@ jobs:
|
||||
timeout-minutes: ${{ matrix.mac && 60 || 40 }}
|
||||
env:
|
||||
RUSTFLAGS: ${{ matrix.rustflags }}
|
||||
# The release's version, built in (horizon_core::release): --version, user agents, crash reports and
|
||||
# telemetry say it. No version-bump commits.
|
||||
HORIZON_VERSION: ${{ needs.decide.outputs.version }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
@@ -162,9 +169,13 @@ jobs:
|
||||
bin=target/release
|
||||
"$bin/horizon-client${{ matrix.exe }}" --help | grep -q -- '--resources'
|
||||
"$bin/horizon-ctl${{ matrix.exe }}" --help > /dev/null
|
||||
"$bin/horizon-prepare${{ matrix.exe }}" --version
|
||||
"$bin/horizon-prepare${{ matrix.exe }}" --help | grep -q -- '--minecraft-dir'
|
||||
"$bin/horizon-server${{ matrix.exe }}" --version
|
||||
# The version is the release's.
|
||||
for binary in horizon-prepare horizon-server; do
|
||||
out=$("$bin/$binary${{ matrix.exe }}" --version | tr -d '\r')
|
||||
echo "$out"
|
||||
[[ "$out" == "$binary $HORIZON_VERSION" ]] || { echo "::error::expected $binary $HORIZON_VERSION"; exit 1; }
|
||||
done
|
||||
- name: Tools from the runner
|
||||
if: runner.environment == 'self-hosted'
|
||||
run: bash tools/ci/runner-env.sh
|
||||
@@ -245,7 +256,7 @@ jobs:
|
||||
folder="dist/${{ matrix.server_dir }}"
|
||||
python3 tools/check_imports.py --server "$folder/horizon-engine" "$folder/horizon-server" "$folder/horizon-prepare"
|
||||
"$folder/horizon-engine" --help | grep -q -- '--resources'
|
||||
"$folder/horizon-server" --version
|
||||
[[ "$("$folder/horizon-server" --version)" == "horizon-server $HORIZON_VERSION" ]]
|
||||
cd dist
|
||||
rm -f "${{ matrix.server_asset }}"
|
||||
tar czf "${{ matrix.server_asset }}" "${{ matrix.server_dir }}"
|
||||
|
||||
@@ -174,7 +174,7 @@ pub fn discovery_url() -> String {
|
||||
fn agent() -> ureq::Agent {
|
||||
ureq::AgentBuilder::new()
|
||||
.timeout(Duration::from_secs(15))
|
||||
.user_agent(concat!("Horizon/", env!("CARGO_PKG_VERSION")))
|
||||
.user_agent(&format!("Horizon/{}", horizon_core::release::VERSION))
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ impl Session {
|
||||
"initialize" => Ok(json!({
|
||||
"protocolVersion": params.get("protocolVersion").and_then(Value::as_str).unwrap_or(PROTOCOL),
|
||||
"capabilities": { "tools": {} },
|
||||
"serverInfo": { "name": "horizon-ctl", "version": env!("CARGO_PKG_VERSION") },
|
||||
"serverInfo": { "name": "horizon-ctl", "version": horizon_core::release::VERSION },
|
||||
"instructions": "Play Horizon, a Rust reimplementation of Minecraft Java Edition. Start with launch (it finds the game installed by the Horizon launcher and opens or creates a world), then read the world with state, inventory, screen, entities and find_block, and act with goto, look_at_block, break, place, interact, click_slot and click_button. Actions block until they finish and report what happened. Coordinates are block coordinates; yaw 0 faces south (+Z).",
|
||||
})),
|
||||
"ping" => Ok(json!({})),
|
||||
|
||||
@@ -105,18 +105,23 @@ impl Report {
|
||||
}
|
||||
}
|
||||
|
||||
/// The release tag (the launcher installs each build in a folder named after it) and the client's
|
||||
/// own version, or just the latter.
|
||||
/// The release this binary is (`v0.2.3`); for a release from before 0.2, its tag and the client's
|
||||
/// crate version; for a build from source, that version alone.
|
||||
pub fn version() -> String {
|
||||
let version = env!("CARGO_PKG_VERSION");
|
||||
match release_tag() {
|
||||
Some(tag) => format!("{tag} (client {version})"),
|
||||
None => version.to_owned(),
|
||||
match (horizon_core::release::RELEASE, release_tag()) {
|
||||
(Some(_), Some(tag)) => tag,
|
||||
(None, Some(tag)) => format!("{tag} (client {version})"),
|
||||
(_, None) => version.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
/// The release this binary came with: launcher installs live in a folder named after the tag.
|
||||
/// The release this binary came with: the version release.yml built in (docs/versioning.md), else
|
||||
/// the folder the launcher installed it in, named after the tag (releases from before 0.2).
|
||||
pub fn release_tag() -> Option<String> {
|
||||
if let Some(version) = horizon_core::release::RELEASE {
|
||||
return Some(format!("v{version}"));
|
||||
}
|
||||
let exe = std::env::current_exe().ok()?;
|
||||
let folder = exe.parent()?.file_name()?.to_str()?;
|
||||
(folder.starts_with('v') && folder[1..].starts_with(|c: char| c.is_ascii_digit()))
|
||||
@@ -517,6 +522,18 @@ pub fn debug_crash_after() -> Option<std::time::Duration> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_release_reports_its_built_in_version() {
|
||||
// release.yml builds with HORIZON_VERSION (docs/versioning.md): `v0.2.3`, wherever it is installed.
|
||||
match horizon_core::release::RELEASE {
|
||||
Some(version) => {
|
||||
assert_eq!(release_tag(), Some(format!("v{version}")));
|
||||
assert_eq!(super::version(), format!("v{version}"));
|
||||
}
|
||||
None => assert!(release_tag().is_none() || super::version().contains("(client ")),
|
||||
}
|
||||
}
|
||||
|
||||
fn report() -> Report {
|
||||
Report {
|
||||
time: chrono::TimeZone::with_ymd_and_hms(&Local, 2026, 10, 14, 9, 5, 7).unwrap(),
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn system() -> System {
|
||||
system
|
||||
}
|
||||
|
||||
/// The release (`v2026.10.15`), or the client's crate version for a build from source.
|
||||
/// The release (`v0.2.3`), or the client's crate version for a build from source.
|
||||
pub fn version() -> String {
|
||||
crate::crash::release_tag().unwrap_or_else(|| format!("dev {}", env!("CARGO_PKG_VERSION")))
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ pub mod storage;
|
||||
pub mod text;
|
||||
pub mod ticks;
|
||||
|
||||
pub mod release;
|
||||
pub mod version;
|
||||
|
||||
pub use version::VANILLA_VERSION;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//! Which Horizon release this build is (docs/versioning.md). Not Minecraft's version: that is
|
||||
//! [`crate::version`], generated from the game's own files.
|
||||
|
||||
/// The release's version (`0.2.3`, no `v`): release.yml builds every release with `HORIZON_VERSION`
|
||||
/// set from its tag, so there are no version-bump commits. None for a build from source.
|
||||
pub const RELEASE: Option<&str> = match option_env!("HORIZON_VERSION") {
|
||||
Some(version) if !version.is_empty() => Some(version),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
/// [`RELEASE`], or this crate's Cargo.toml version for a build from source: what `--version`, user
|
||||
/// agents and reports say.
|
||||
pub const VERSION: &str = match RELEASE {
|
||||
Some(version) => version,
|
||||
None => env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn the_version_is_the_release_or_the_crate() {
|
||||
assert_eq!(
|
||||
super::RELEASE,
|
||||
option_env!("HORIZON_VERSION").filter(|v| !v.is_empty())
|
||||
);
|
||||
assert_eq!(
|
||||
super::VERSION,
|
||||
super::RELEASE.unwrap_or(env!("CARGO_PKG_VERSION"))
|
||||
);
|
||||
assert!(!super::VERSION.starts_with('v'));
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,13 @@ use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::ExitCode;
|
||||
|
||||
/// This release's version: release.yml builds it with `HORIZON_VERSION` from the tag
|
||||
/// (docs/versioning.md); a build from source says Cargo.toml's.
|
||||
const VERSION: &str = match option_env!("HORIZON_VERSION") {
|
||||
Some(version) if !version.is_empty() => version,
|
||||
_ => env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
|
||||
const HELP: &str = "\
|
||||
horizon-prepare: prepare Horizon's resources from your own Minecraft Java Edition
|
||||
|
||||
@@ -92,7 +99,7 @@ fn main() -> ExitCode {
|
||||
return ExitCode::SUCCESS;
|
||||
}
|
||||
"-V" | "--version" => {
|
||||
println!("horizon-prepare {}", env!("CARGO_PKG_VERSION"));
|
||||
println!("horizon-prepare {VERSION}");
|
||||
return ExitCode::SUCCESS;
|
||||
}
|
||||
_ => Err(format!("unrecognized argument: {text}")),
|
||||
|
||||
@@ -45,7 +45,7 @@ pub fn resolve(name: &str, online: bool) -> Option<NameAndId> {
|
||||
pub fn find_by_name(discovery: &str, name: &str) -> Option<NameAndId> {
|
||||
let agent = ureq::AgentBuilder::new()
|
||||
.timeout(Duration::from_secs(15))
|
||||
.user_agent(concat!("Horizon/", env!("CARGO_PKG_VERSION")))
|
||||
.user_agent(&format!("Horizon/{}", horizon_core::release::VERSION))
|
||||
.build();
|
||||
let doc = json::parse(&agent.get(discovery).call().ok()?.into_string().ok()?, true).ok()?;
|
||||
let url = endpoint(&doc, "profiles", "getByName")?.replace("{name}", &name.to_lowercase());
|
||||
@@ -61,7 +61,7 @@ pub fn fetch_profile_key_keys(discovery: &str) -> Result<Vec<RsaPublicKey>, &'st
|
||||
const FAILED: &str = "Failed to request Minecraft Services public key";
|
||||
let agent = ureq::AgentBuilder::new()
|
||||
.timeout(Duration::from_secs(15))
|
||||
.user_agent(concat!("Horizon/", env!("CARGO_PKG_VERSION")))
|
||||
.user_agent(&format!("Horizon/{}", horizon_core::release::VERSION))
|
||||
.build();
|
||||
let get = |url: &str| agent.get(url).call().ok()?.into_string().ok();
|
||||
let doc = get(discovery)
|
||||
|
||||
@@ -286,7 +286,7 @@ fn status(shared: &Shared) -> Value {
|
||||
let state = shared.state.lock().unwrap();
|
||||
json!({
|
||||
"phase": state.phase.name(),
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"version": crate::VERSION,
|
||||
"pid": std::process::id(),
|
||||
"uptime_seconds": shared.started.elapsed().as_secs(),
|
||||
"engine_pid": state.engine_pid,
|
||||
|
||||
@@ -18,6 +18,13 @@ mod update;
|
||||
|
||||
use std::{path::PathBuf, process::ExitCode};
|
||||
|
||||
/// This release's version: release.yml builds it with `HORIZON_VERSION` from the tag
|
||||
/// (docs/versioning.md); a build from source says Cargo.toml's.
|
||||
const VERSION: &str = match option_env!("HORIZON_VERSION") {
|
||||
Some(version) if !version.is_empty() => version,
|
||||
_ => env!("CARGO_PKG_VERSION"),
|
||||
};
|
||||
|
||||
const HELP: &str = "\
|
||||
horizon-server: host a Horizon (Minecraft Java Edition 26.3) server
|
||||
|
||||
@@ -86,7 +93,7 @@ fn main() -> ExitCode {
|
||||
Ok(())
|
||||
}
|
||||
Some("version" | "-V" | "--version") => {
|
||||
println!("horizon-server {}", env!("CARGO_PKG_VERSION"));
|
||||
println!("horizon-server {VERSION}");
|
||||
Ok(())
|
||||
}
|
||||
Some("init") => init_answers(&args[1..]).and_then(|a| init::run(&dir, a)),
|
||||
|
||||
@@ -307,7 +307,7 @@ pub fn benchmark(repeats: usize) -> Result<PathBuf, String> {
|
||||
if let Ok(data) = serde_json::to_value(report.for_upload()) {
|
||||
let item = horizon_telemetry::Item::new(
|
||||
horizon_telemetry::Source::Launcher,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
crate::backend::VERSION,
|
||||
horizon_telemetry::Payload::Benchmark(data),
|
||||
);
|
||||
let _ = horizon_telemetry::outbox::push(&crate::backend::game_home(), &item);
|
||||
@@ -320,7 +320,7 @@ pub fn benchmark(repeats: usize) -> Result<PathBuf, String> {
|
||||
fn app() -> App {
|
||||
App {
|
||||
name: "horizon-launcher".into(),
|
||||
version: env!("CARGO_PKG_VERSION").into(),
|
||||
version: crate::backend::VERSION.into(),
|
||||
..App::default()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user