Merge pull request #1129 from ludovic111/feat/release-line
🤖 Agent: merged. Verify and CI parity pass, and an independent review found no blocking issue. The release, launcher and promote workflows stay disabled with RELEASES_PAUSED=1. Without .github/release-line.txt the train decides exactly as before (checked against every existing tag).
This commit is contained in:
@@ -3,8 +3,10 @@ name: launcher
|
||||
# push to main that changes the launcher or a crate it builds in (the paths below),
|
||||
# every 10 minutes (a release waiting for merges to settle goes out) and by hand, tools/release_train.py decides as
|
||||
# for the game.
|
||||
# A release is launcher-vX.Y.Z: the patch after the last launcher tag, or the next minor when a merged pull
|
||||
# request is labelled feature. The version is given to the build (HORIZON_LAUNCHER_VERSION): no bump commits.
|
||||
# A release is launcher@X.Y.Z on the release line in .github/release-line.txt (docs/versioning.md); without it
|
||||
# launcher-vX.Y.Z, the patch after the last launcher tag or the next minor when a merged pull request is labelled
|
||||
# feature. The version and the tag are given to the build (HORIZON_LAUNCHER_VERSION, HORIZON_LAUNCHER_TAG): no bump
|
||||
# commits.
|
||||
# Never marked latest. Pushes to launcher branches only build. RELEASES_PAUSED=1 stops releases.
|
||||
# macOS: with the repository variable MACOS_SIGN_IDENTITY set, Horizon.app and the .dmg are signed with
|
||||
# Developer ID, notarized and stapled, from the runner's signing keychain (packaging/macos/README.md);
|
||||
@@ -75,7 +77,8 @@ jobs:
|
||||
python3 tools/release_train.py decide --kind launcher ${HEAD_SHA:+--head "$HEAD_SHA"} ${FORCE:+--force} | tee decision.json
|
||||
echo "### $(jq -r '.reason' decision.json)" >> "$GITHUB_STEP_SUMMARY"
|
||||
tag=$(jq -r '.tag' decision.json)
|
||||
echo "version=${tag#launcher-v}" >> "$GITHUB_OUTPUT"
|
||||
version=${tag#launcher-v}
|
||||
echo "version=${version#launcher@}" >> "$GITHUB_OUTPUT"
|
||||
# A dry run (and a launcher branch's push) builds whatever the decision.
|
||||
if [[ "${{ steps.mode.outputs.dry_run }}" == true ]]; then
|
||||
echo "release=true" >> "$GITHUB_OUTPUT"
|
||||
@@ -113,9 +116,10 @@ jobs:
|
||||
# Horizon's Azure app for Microsoft sign-in (docs/microsoft-account.md): a repository
|
||||
# variable, not a secret. Unset, the launcher says sign-in is not configured.
|
||||
HORIZON_MSA_CLIENT_ID: ${{ vars.HORIZON_MSA_CLIENT_ID }}
|
||||
# The release's version, built in (launcher/src/backend.rs VERSION); a launcher branch's build keeps
|
||||
# Cargo.toml's.
|
||||
# The release's version and tag, built in (launcher/src/backend.rs VERSION and own_tag: the tag says which
|
||||
# line it is on, docs/versioning.md); a launcher branch's build keeps Cargo.toml's.
|
||||
HORIZON_LAUNCHER_VERSION: ${{ (github.event_name != 'push' || github.ref == 'refs/heads/main') && needs.decide.outputs.version || '' }}
|
||||
HORIZON_LAUNCHER_TAG: ${{ (github.event_name != 'push' || github.ref == 'refs/heads/main') && needs.decide.outputs.tag || '' }}
|
||||
defaults:
|
||||
run:
|
||||
working-directory: launcher
|
||||
|
||||
@@ -6,7 +6,8 @@ name: release
|
||||
# RELEASES_PAUSED=1 (repository variable) stops them.
|
||||
# Builds Linux (an older Ubuntu, so the binary runs on any recent distribution and on NixOS through nix-ld) and
|
||||
# Windows on GitHub, macOS on the Mac mini's runner (MAC_RUNNER=macos-latest sends it to GitHub), then
|
||||
# publishes vYYYY.MM.DD[.N] with notes from the merged pull requests, as a beta (a pre-release) that promote.yml makes
|
||||
# publishes vX.Y.Z on the release line in .github/release-line.txt (docs/versioning.md; without it, the dated
|
||||
# vYYYY.MM.DD[.N] from before 0.2) with notes from the merged pull requests, as a beta (a pre-release) that promote.yml makes
|
||||
# stable after 6 hours. macOS: with the repository variable MACOS_SIGN_IDENTITY set, the programs are signed with
|
||||
# Developer ID and the hardened runtime and the zip is notarized, from the runner's signing keychain
|
||||
# (packaging/macos/README.md); unset (forks), ad hoc.
|
||||
|
||||
+28
-11
@@ -100,7 +100,7 @@ flowchart LR
|
||||
windows["Windows x64<br/>GitHub windows-latest"]
|
||||
mac["macOS arm64<br/>Mac mini runner<br/>+ offscreen game run"]
|
||||
end
|
||||
build --> publish["publish vYYYY.MM.DD[.N] as a beta<br/>notes from the merged PRs"]
|
||||
build --> publish["publish vX.Y.Z as a beta<br/>notes from the merged PRs"]
|
||||
publish --> beta(["launchers with Beta builds on install it"])
|
||||
publish --> promote{"promote.yml, every 30 min:<br/>6 h old, smoke test, no release-blocker"}
|
||||
promote --> stable["stable and latest<br/>notes since the last stable"]
|
||||
@@ -125,6 +125,18 @@ commits) since the last **published** game release:
|
||||
- One release at a time (concurrency group `game-release`); a run that finds nothing new does nothing.
|
||||
- A scheduled or hand-started run releases main's newest commit whose `checks` passed; after `checks`, the commit
|
||||
they passed on.
|
||||
- The first release of a new release line (below) goes out at once, without waiting for a pull request.
|
||||
|
||||
### Tags
|
||||
|
||||
How releases are numbered, and how installs from before 0.2 reach it: [versioning.md](versioning.md).
|
||||
|
||||
- With a release line in `.github/release-line.txt` (`MAJOR.MINOR`, e.g. `0.2`), a game release is `vMAJOR.MINOR.PATCH`,
|
||||
the patch after the newest release tagged on that line (`v0.2.0` first). A `feature` label doesn't change the line:
|
||||
only that file does, by pull request.
|
||||
- Without the file (every release before 0.2), `vYYYY.MM.DD`, then `.01`, `.02`… the same UTC day.
|
||||
- Every reader (`release_train.py`, `release_channels.py`, the launcher, `horizon-server update`, the website) ranks
|
||||
every `vX.Y.Z` tag above every dated one.
|
||||
|
||||
### Labels
|
||||
|
||||
@@ -158,7 +170,9 @@ runs the game: GitHub's runners have neither a GPU worth the name nor the game f
|
||||
|
||||
`tools/release_train.py notes` writes them from the same pull requests:
|
||||
|
||||
- the title, `Horizon 2026.10.15.01: <the first pull request titles>` (a day's later releases count .01, .02…, two digits so GitHub's releases page, which sorts them as text, keeps them in order), features first, newest first;
|
||||
- the title, `Horizon 0.2.3: <the first pull request titles>` (before 0.2, `Horizon 2026.10.15.01: …`, a day's later releases counting .01, .02…, two digits so GitHub's releases page, which sorts them as text, kept them in order), features first, newest first;
|
||||
- a line's first release (`X.Y.0`) opens with a paragraph that says so; 0.2.0's says releases are numbered from now
|
||||
on and how a server that says it is up to date takes it;
|
||||
- `### New` (label `feature`) and `### Fixed` (the rest), one line per pull request: its title, its number, the
|
||||
issues it closes;
|
||||
- `### Known issues`: the bullets of [docs/known-issues.md](known-issues.md);
|
||||
@@ -275,7 +289,7 @@ While paused, runs still decide and say why in their summary; `force=true` still
|
||||
A bad release is withdrawn by turning it back into a draft:
|
||||
|
||||
```sh
|
||||
gh release edit v2026.10.15.01 --draft
|
||||
gh release edit v0.2.3 --draft
|
||||
```
|
||||
|
||||
A beta that is not promoted yet needs no rollback: label an issue about it `release-blocker`. For a stable
|
||||
@@ -295,23 +309,26 @@ and by hand; pushes to `launcher` and `launcher-*` branches only build.
|
||||
- `tools/release_train.py decide --kind launcher` counts the pull requests merged since the last published
|
||||
launcher release that changed those paths (not `launcher/links.json`, which the launcher reads from main, nor
|
||||
tests or Markdown), with the same settling rule (15 minutes, at most an hour), `release-now`, `skip-release` and `RELEASES_PAUSED`.
|
||||
- The tag is `launcher-vX.Y.Z`: the patch after the last launcher tag, or the next minor (`X.Y+1.0`) when one of
|
||||
those pull requests is labelled `feature`.
|
||||
- No version-bump commits: the build gets the version in `HORIZON_LAUNCHER_VERSION`, which
|
||||
`launcher/src/backend.rs` reads with `option_env!` (falling back to `Cargo.toml`'s), so `--version`, the window,
|
||||
the User-Agent and the self-update comparison all use it. Each build checks `--version` says it.
|
||||
- The tag is `launcher@X.Y.Z` on the release line (`launcher@0.2.0` first; the game and the launcher count their
|
||||
patches separately). Without `.github/release-line.txt`, `launcher-vX.Y.Z`: the patch after the last launcher tag,
|
||||
or the next minor (`X.Y+1.0`) when one of those pull requests is labelled `feature`. `launcher-v0.2.0` was taken
|
||||
long before 0.2, hence the new prefix.
|
||||
- No version-bump commits: the build gets the version in `HORIZON_LAUNCHER_VERSION` and the tag in
|
||||
`HORIZON_LAUNCHER_TAG`, which `launcher/src/backend.rs` reads with `option_env!` (falling back to `Cargo.toml`'s),
|
||||
so `--version`, the window, the User-Agent and the self-update comparison all use them. Each build checks
|
||||
`--version` says it.
|
||||
- Linux on GitHub `ubuntu-22.04`, Windows on `windows-latest`, macOS on the Mac mini's runner; each runs the
|
||||
launcher's tests, checks its libraries, and installs the latest game release with the new launcher.
|
||||
- Published with `--latest=false`: the repository's latest release stays a game release. Notes list the pull
|
||||
requests under New and Fixed; Kira posts launcher releases without pinging.
|
||||
|
||||
Starting by hand, pausing and rolling back work as for the game (`gh workflow run launcher …`,
|
||||
`RELEASES_PAUSED`, `gh release edit launcher-vX.Y.Z --draft`). Launchers older than the withdrawn release then
|
||||
`RELEASES_PAUSED`, `gh release edit launcher@X.Y.Z --draft`). Launchers older than the withdrawn release then
|
||||
see the previous one as the newest; launchers that already updated keep running.
|
||||
|
||||
With several game releases a day, the newest launcher release soon falls out of the newest 100 releases the
|
||||
launcher and the website read: both then look the newest `launcher-v` tags up one by one
|
||||
(`git/matching-refs/tags/launcher-v`, then `releases/tags/<tag>`).
|
||||
launcher and the website read: both then look the newest launcher tags up one by one
|
||||
(`git/matching-refs/tags/launcher@`, then `launcher-v` if there is none, then `releases/tags/<tag>`).
|
||||
|
||||
## Nightly audit
|
||||
|
||||
|
||||
@@ -80,6 +80,23 @@ class ReleaseChannelTests(unittest.TestCase):
|
||||
same = release("v2026.10.18.04", 30, prerelease=False)
|
||||
self.assertIsNone(channels.choose([same], [], NOW, tag="v2026.10.18.04", force=True)[0])
|
||||
|
||||
def test_0_2_follows_the_dated_releases(self):
|
||||
bridge = release("v2026.10.21", 30, prerelease=False)
|
||||
first = release("v0.2.0", 7)
|
||||
chosen, why = channels.choose([bridge, first], [], NOW)
|
||||
self.assertEqual(chosen["tag_name"], "v0.2.0", why)
|
||||
stable = release("v0.2.0", 30, prerelease=False)
|
||||
older = release("v2026.10.22", 8)
|
||||
self.assertIsNone(channels.choose([stable, older], [], NOW)[0], "a dated beta never follows 0.2")
|
||||
chosen, why = channels.choose([stable, older], [], NOW, tag="v2026.10.22", force=True)
|
||||
self.assertIsNone(chosen)
|
||||
self.assertIn("not newer than the stable v0.2.0", why)
|
||||
patch = release("v0.2.1", 7)
|
||||
self.assertEqual(channels.choose([stable, older, patch], [], NOW)[0]["tag_name"], "v0.2.1")
|
||||
self.assertEqual(channels.stable([stable, bridge])["tag_name"], "v0.2.0")
|
||||
launcher = release("launcher@0.2.0", 7)
|
||||
self.assertIsNone(channels.choose([bridge, launcher], [], NOW)[0], "launcher releases are never game betas")
|
||||
|
||||
def test_a_stall_is_reported_once_the_oldest_waiting_beta_is_a_day_old(self):
|
||||
self.assertIsNone(channels.stalled([STABLE, release("v2026.10.19", 23), release("v2026.10.19.01", 2)], NOW))
|
||||
releases = [STABLE, release("v2026.10.19", 25), release("v2026.10.19.01", 2)]
|
||||
|
||||
@@ -52,6 +52,71 @@ class ReleaseTrainTests(unittest.TestCase):
|
||||
self.assertEqual(train.next_launcher_tag(tags, minor=False), "launcher-v0.1.11")
|
||||
self.assertEqual(train.next_launcher_tag(tags, minor=True), "launcher-v0.2.0")
|
||||
|
||||
def test_0_2_tags_follow_every_tag_from_before(self):
|
||||
order = ["launcher-v0.1.9", "launcher-v0.16.0", "v2026.10.19.15", "v2026.10.21", "v0.2.0-beta.1", "v0.2.0",
|
||||
"v0.2.1-beta", "v0.2.1-beta.1", "v0.2.1-beta.2", "v0.2.1-beta.11", "v0.2.1-rc.1", "v0.2.1", "v0.2.9",
|
||||
"v0.2.10", "v0.3.0-1", "v0.3.0-alpha", "v0.3.0", "v1.0.0"]
|
||||
self.assertEqual(sorted(reversed(order), key=train.tag_key), order)
|
||||
self.assertGreater(train.tag_key("launcher@0.2.0"), train.tag_key("launcher-v0.16.0"))
|
||||
self.assertEqual(train.tag_key("v2026.10.19"), train.tag_key("v2026.10.19.0"))
|
||||
for tag in ["v0.2.0", "v0.3.0-rc.1", "v2026.10.21", "v2026.10.19.15"]:
|
||||
self.assertTrue(train.is_game_tag(tag), tag)
|
||||
for tag in ["launcher@0.2.0", "launcher-v0.2.0", "v0.2", "vnext", "v2026.10.21-x", "v0.2.0-"]:
|
||||
self.assertFalse(train.is_game_tag(tag), tag)
|
||||
self.assertTrue(train.is_launcher_tag("launcher@0.2.0") and train.is_launcher_tag("launcher-v0.16.0"))
|
||||
self.assertFalse(train.is_launcher_tag("v0.2.0"))
|
||||
|
||||
def test_tags_on_a_release_line(self):
|
||||
line = (0, 2)
|
||||
before = ["v2026.10.19.15", "v2026.10.21", "launcher-v0.16.0", "launcher-v0.2.0", "launcher-v0.2.1"]
|
||||
today = dt.date(2026, 10, 23)
|
||||
self.assertEqual(train.next_game_tag(before, today, line), "v0.2.0")
|
||||
self.assertEqual(train.next_launcher_tag(before, minor=True, line=line), "launcher@0.2.0")
|
||||
self.assertTrue(train.first_on_line(before, "v", line))
|
||||
after = before + ["v0.2.0", "v0.2.1", "launcher@0.2.0", "v0.3.0-rc.1"]
|
||||
self.assertEqual(train.next_game_tag(after, today, line), "v0.2.2")
|
||||
# A feature doesn't move the line; only .github/release-line.txt does.
|
||||
self.assertEqual(train.next_launcher_tag(after, minor=True, line=line), "launcher@0.2.1")
|
||||
self.assertFalse(train.first_on_line(after, "v", line))
|
||||
self.assertTrue(train.first_on_line(after, "v", (0, 3)), "a pre-release isn't the line's first release")
|
||||
self.assertEqual(train.next_game_tag(after, today, (0, 3)), "v0.3.0")
|
||||
with self.assertRaises(SystemExit):
|
||||
train.next_game_tag(after + ["v0.3.0"], today, line)
|
||||
# Without a line, the tags from before 0.2, whatever 0.2 tags exist.
|
||||
self.assertEqual(train.next_game_tag(before, today), "v2026.10.23")
|
||||
self.assertEqual(train.next_launcher_tag(after, minor=False), "launcher-v0.16.1")
|
||||
|
||||
def test_the_release_line_file(self):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
path = Path(folder) / "release-line.txt"
|
||||
self.assertIsNone(train.release_line(path))
|
||||
path.write_text("0.2\n")
|
||||
self.assertEqual(train.release_line(path), (0, 2))
|
||||
path.write_text("0.2.0\n")
|
||||
with self.assertRaises(SystemExit):
|
||||
train.release_line(path)
|
||||
# Not set on main until the switch to 0.2 (docs/versioning.md).
|
||||
self.assertIsNone(train.release_line()) if not train.LINE_FILE.exists() else self.assertIsNotNone(train.release_line())
|
||||
|
||||
def test_a_new_line_releases_at_once_unless_paused(self):
|
||||
self.assertEqual(train.decision("game", [], NOW, new_line="0.2"), (True, "the first release of 0.2"))
|
||||
self.assertFalse(train.decision("game", [], NOW, paused=True, new_line="0.2")[0])
|
||||
self.assertFalse(train.decision("game", [], NOW)[0])
|
||||
|
||||
def test_the_first_release_of_0_2_says_what_changed(self):
|
||||
title, body = train.notes("game", "v0.2.0", [pr(1)], [], beta=True, previous="v2026.10.21")
|
||||
self.assertTrue(title.startswith("Horizon 0.2.0: "), title)
|
||||
self.assertTrue(body.startswith("Horizon is numbered from now on: this is Horizon 0.2.0, the release after 2026.10.21."))
|
||||
self.assertIn("`horizon-server update --version v0.2.0`", body)
|
||||
title, body = train.notes("launcher", "launcher@0.2.0", [], [], previous="launcher-v0.17.0")
|
||||
self.assertEqual(title, "Horizon launcher 0.2.0")
|
||||
self.assertIn("the release after launcher 0.17.0", body)
|
||||
self.assertIn("Rebuilt from the latest main.", body)
|
||||
self.assertTrue(train.notes("game", "v0.3.0", [pr(1)], [], previous="v0.2.14")[1].startswith("The first release of Horizon 0.3."))
|
||||
for version, previous in [("v0.2.1", "v0.2.0"), ("v0.3.0-rc.1", "v0.2.9"), ("v2026.10.23", "v2026.10.21")]:
|
||||
body = train.notes("game", version, [pr(1)], [], previous=previous)[1]
|
||||
self.assertTrue(body.startswith("### Fixed"), (version, body))
|
||||
|
||||
def test_decision(self):
|
||||
minute = dt.timedelta(minutes=1)
|
||||
decide = lambda prs, **kw: train.decision("game", prs, NOW, **kw)[0]
|
||||
|
||||
@@ -29,27 +29,20 @@ import datetime as dt
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
from tools.release_train import is_game_tag, tag_key # noqa: E402 (vYYYY.MM.DD[.N] and v0.2.0: docs/versioning.md)
|
||||
|
||||
REPO = os.environ.get("GITHUB_REPOSITORY", "ludovic111/horizon")
|
||||
PROMOTE_AFTER = dt.timedelta(hours=6)
|
||||
SMOKE_ASSET = "smoke-test.json"
|
||||
BLOCKER = "release-blocker"
|
||||
STALL_AFTER = dt.timedelta(hours=24)
|
||||
STALLED = "Promotion to stable has stalled"
|
||||
GAME_TAG = re.compile(r"v\d{4}\.\d{2}\.\d{2}(?:\.\d+)?")
|
||||
|
||||
|
||||
def tag_key(tag):
|
||||
"""A game tag's numbers, four of them (v2026.10.19 is (2026, 10, 19, 0)), so tags compare."""
|
||||
version = tuple(int(part) for part in re.findall(r"\d+", tag))
|
||||
return version + (0,) * (4 - len(version))
|
||||
|
||||
|
||||
def parse_time(text):
|
||||
return dt.datetime.fromisoformat(text.replace("Z", "+00:00")) if text else None
|
||||
|
||||
@@ -90,7 +83,7 @@ def reasons_against(release, current, blockers, now, by_hand=False):
|
||||
|
||||
def choose(releases, blockers, now, tag=None, force=False):
|
||||
"""(the beta to promote or None, a line saying why) for the game releases `releases`."""
|
||||
games = [r for r in releases if not r["draft"] and GAME_TAG.fullmatch(r["tag_name"])]
|
||||
games = [r for r in releases if not r["draft"] and is_game_tag(r["tag_name"])]
|
||||
current = stable(games)
|
||||
if tag:
|
||||
release = next((r for r in games if r["tag_name"] == tag), None)
|
||||
@@ -116,7 +109,7 @@ def choose(releases, blockers, now, tag=None, force=False):
|
||||
|
||||
def stalled(releases, now):
|
||||
"""(the oldest beta newer than the stable release, how long it has waited) once that is STALL_AFTER, else None."""
|
||||
games = [r for r in releases if not r["draft"] and GAME_TAG.fullmatch(r["tag_name"])]
|
||||
games = [r for r in releases if not r["draft"] and is_game_tag(r["tag_name"])]
|
||||
current = stable(games)
|
||||
waiting = [r for r in games if r["prerelease"] and (not current or tag_key(r["tag_name"]) > tag_key(current["tag_name"]))]
|
||||
if not waiting:
|
||||
@@ -129,7 +122,7 @@ def stalled(releases, now):
|
||||
def stall_issue(releases, stall, reason):
|
||||
"""The title and body of the issue saying promotion has stalled."""
|
||||
oldest, age = stall
|
||||
current = stable([r for r in releases if not r["draft"] and GAME_TAG.fullmatch(r["tag_name"])])
|
||||
current = stable([r for r in releases if not r["draft"] and is_game_tag(r["tag_name"])])
|
||||
hours = int(age.total_seconds() // 3600)
|
||||
body = (f"Opened by .github/workflows/promote.yml, not by a person.\n\n"
|
||||
f"No beta has become stable for {hours} hours: {oldest['tag_name']} has waited since "
|
||||
|
||||
+118
-19
@@ -12,8 +12,12 @@ of merges becomes one release), or the oldest at least MAX_WAIT ago (merges that
|
||||
of those pull requests is labelled release-now. Pull requests labelled skip-release (work players don't see) don't count
|
||||
towards a release and aren't listed in the notes. RELEASES_PAUSED=1 (a repository variable) stops automatic releases.
|
||||
|
||||
Game releases are tagged vYYYY.MM.DD, then .01, .02 the same UTC day; launcher releases launcher-vX.Y.Z, the
|
||||
patch after the last launcher tag, or the next minor when a merged pull request is labelled feature. Notes:
|
||||
Tags (docs/versioning.md): with a release line in .github/release-line.txt (MAJOR.MINOR, e.g. 0.2), game releases
|
||||
are vMAJOR.MINOR.PATCH and launcher releases launcher@MAJOR.MINOR.PATCH, each the patch after the last tag of its kind
|
||||
on the line (MAJOR.MINOR.0 first: a line's first release goes out without waiting for a pull request). Without the
|
||||
file, the tags from before 0.2: vYYYY.MM.DD, then .01, .02 the same UTC day, and launcher-vX.Y.Z, the patch after
|
||||
the last launcher tag or the next minor when a merged pull request is labelled feature. Every 0.2 tag is newer than
|
||||
every tag from before (tag_key). Notes:
|
||||
"### New" lists the pull requests labelled feature, "### Fixed" the others, "### Known issues" the bullets of
|
||||
docs/known-issues.md. Game releases go out as betas (GitHub pre-releases) and tools/release_channels.py promotes
|
||||
them to stable; a beta's notes cover what changed since the release before it (beta or stable), a promoted
|
||||
@@ -39,6 +43,14 @@ MAX_WAIT = dt.timedelta(hours=1)
|
||||
PROPER = {"Horizon", "Horizon's", "Minecraft", "Mojang", "Microsoft", "Java", "Xbox", "PlayStation", "Steam", "Windows",
|
||||
"Linux", "LAN", "Kira", "Discord", "Wayland", "Hyprland", "F3", "GUI", "UI"}
|
||||
EXPORTERS = "mods/horizon/src/test/java/dev/horizonlab/parity/"
|
||||
# The release line (docs/versioning.md): MAJOR.MINOR. Without the file, releases keep the tags from before 0.2.
|
||||
LINE_FILE = ROOT / ".github" / "release-line.txt"
|
||||
SEMVER = r"(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?"
|
||||
# Semver's majors stay below this; a date tag's first number is a year.
|
||||
FIRST_YEAR = 1000
|
||||
GAME_PREFIX = "v"
|
||||
LAUNCHER_PREFIX = "launcher@"
|
||||
OLD_LAUNCHER_PREFIX = "launcher-v"
|
||||
|
||||
# What players run. Documentation (*.md), tests, benchmarks and harness probes (examples/) never count.
|
||||
GAME_PATHS = ["crates/", "xtask/", "packaging/", "Cargo.toml", "Cargo.lock", "research-lock.json"]
|
||||
@@ -95,23 +107,75 @@ def player_facing(path, kind, exporter_paths=frozenset()):
|
||||
return any(path == p or path.startswith(p) for p in GAME_PATHS) or path in exporter_paths
|
||||
|
||||
|
||||
def semver(tag, prefix):
|
||||
"""(major, minor, patch, pre-release or None) of a 0.2 tag `<prefix>X.Y.Z[-PRE]`, else None."""
|
||||
match = re.fullmatch(re.escape(prefix) + SEMVER, tag)
|
||||
if not match or int(match[1]) >= FIRST_YEAR:
|
||||
return None
|
||||
return int(match[1]), int(match[2]), int(match[3]), match[4]
|
||||
|
||||
|
||||
def is_game_tag(tag):
|
||||
return re.fullmatch(r"v\d{4}\.\d{2}\.\d{2}(\.\d+)?", tag) is not None
|
||||
return re.fullmatch(r"v\d{4}\.\d{2}\.\d{2}(\.\d+)?", tag) is not None or semver(tag, GAME_PREFIX) is not None
|
||||
|
||||
|
||||
def is_launcher_tag(tag):
|
||||
return re.fullmatch(r"launcher-v\d+\.\d+\.\d+", tag) is not None
|
||||
return re.fullmatch(r"launcher-v\d+\.\d+\.\d+", tag) is not None or semver(tag, LAUNCHER_PREFIX) is not None
|
||||
|
||||
|
||||
def tag_key(tag):
|
||||
return tuple(int(part) for part in re.findall(r"\d+", tag))
|
||||
"""A tag's place among releases (docs/versioning.md): the tags from before 0.2 (vYYYY.MM.DD[.N],
|
||||
launcher-vX.Y.Z) by their numbers, trailing zeros dropped (v2026.10.19 is v2026.10.19.0); then every 0.2 tag
|
||||
(vX.Y.Z, launcher@X.Y.Z) in semver's order, a pre-release (v0.3.0-rc.1) before its release."""
|
||||
version = semver(tag, GAME_PREFIX) or semver(tag, LAUNCHER_PREFIX)
|
||||
if version is None:
|
||||
numbers = [int(part) for part in re.findall(r"\d+", tag)]
|
||||
while numbers and numbers[-1] == 0:
|
||||
numbers.pop()
|
||||
return 0, tuple(numbers), ()
|
||||
*numbers, pre = version
|
||||
# A release follows its pre-releases; their identifiers compare one by one, numbers before words.
|
||||
rank = (1,) if pre is None else (0, tuple((0, int(i), "") if i.isdigit() else (1, 0, i) for i in pre.split(".")))
|
||||
return 1, tuple(numbers), rank
|
||||
|
||||
|
||||
def next_game_tag(tags, today):
|
||||
"""vYYYY.MM.DD, or .01, .02... when that day already has a tag (drafts and rolled-back releases included).
|
||||
def release_line(path=LINE_FILE):
|
||||
"""(major, minor) of the release line, or None without the file (the tags from before 0.2)."""
|
||||
if not path.exists():
|
||||
return None
|
||||
text = path.read_text().strip()
|
||||
match = re.fullmatch(r"(\d+)\.(\d+)", text)
|
||||
if not match:
|
||||
raise SystemExit(f"{path}: a release line is MAJOR.MINOR, like 0.2 (got {text!r})")
|
||||
return int(match[1]), int(match[2])
|
||||
|
||||
|
||||
def next_on_line(tags, prefix, line):
|
||||
"""<prefix>MAJOR.MINOR.PATCH: the patch after the newest release tagged on the line (drafts and rolled-back
|
||||
releases included; a hand-made pre-release such as v0.3.0-rc.1 is not one), or .0. Never a line below one that
|
||||
has tags: GitHub's latest release only moves forward."""
|
||||
major, minor = line
|
||||
versions = [v for v in (semver(tag, prefix) for tag in tags) if v]
|
||||
above = [v for v in versions if (v[0], v[1]) > line and v[3] is None]
|
||||
if above:
|
||||
raise SystemExit(f"{LINE_FILE.name} says {major}.{minor}, but {prefix}{'.'.join(map(str, above[0][:3]))} exists")
|
||||
patches = [v[2] for v in versions if (v[0], v[1]) == line and v[3] is None]
|
||||
return f"{prefix}{major}.{minor}.{max(patches) + 1 if patches else 0}"
|
||||
|
||||
|
||||
def first_on_line(tags, prefix, line):
|
||||
"""Whether no release of this kind is tagged on the line yet (its first goes out at once)."""
|
||||
return not any(v and (v[0], v[1]) == line and v[3] is None for v in (semver(tag, prefix) for tag in tags))
|
||||
|
||||
|
||||
def next_game_tag(tags, today, line=None):
|
||||
"""vMAJOR.MINOR.PATCH on a release line; before 0.2, vYYYY.MM.DD, or .01, .02... when that day already has a
|
||||
tag (drafts and rolled-back releases included).
|
||||
|
||||
The counter has two digits because GitHub's releases page sorts a day's tags as text: .9 went above .18.
|
||||
Every reader compares the numbers as integers, so the unpadded tags from before still order correctly."""
|
||||
if line:
|
||||
return next_on_line(tags, GAME_PREFIX, line)
|
||||
day = f"v{today:%Y.%m.%d}"
|
||||
taken = [tag for tag in tags if tag == day or tag.startswith(day + ".")]
|
||||
if not taken:
|
||||
@@ -119,8 +183,13 @@ def next_game_tag(tags, today):
|
||||
return f"{day}.{max(int(tag.split('.')[3]) if tag.count('.') == 3 else 0 for tag in taken) + 1:02d}"
|
||||
|
||||
|
||||
def next_launcher_tag(tags, minor):
|
||||
versions = sorted((tag_key(tag) for tag in tags if is_launcher_tag(tag)), reverse=True)
|
||||
def next_launcher_tag(tags, minor, line=None):
|
||||
"""launcher@MAJOR.MINOR.PATCH on a release line (a feature doesn't change the line); before 0.2,
|
||||
launcher-vX.Y.Z, the next patch or with minor the next minor."""
|
||||
if line:
|
||||
return next_on_line(tags, LAUNCHER_PREFIX, line)
|
||||
versions = sorted((tuple(int(part) for part in re.findall(r"\d+", tag)) for tag in tags
|
||||
if tag.startswith(OLD_LAUNCHER_PREFIX) and is_launcher_tag(tag)), reverse=True)
|
||||
major, minor_, patch = versions[0] if versions else (0, 1, 0)
|
||||
return f"launcher-v{major}.{minor_ + 1}.0" if minor else f"launcher-v{major}.{minor_}.{patch + 1}"
|
||||
|
||||
@@ -168,9 +237,10 @@ def last_release(releases, kind):
|
||||
return max(ours, key=lambda release: tag_key(release["tag_name"]), default=None)
|
||||
|
||||
|
||||
def decision(kind, prs, now, paused=False, force=False):
|
||||
def decision(kind, prs, now, paused=False, force=False, new_line=None):
|
||||
"""Whether to release now, and why. prs: the merged pull requests since the last release, each with the
|
||||
files it changed under "paths" (player-facing ones only) and when it merged ("merged_at")."""
|
||||
files it changed under "paths" (player-facing ones only) and when it merged ("merged_at"). new_line: the
|
||||
release line ("0.2") when it has no release of this kind yet; its first goes out at once."""
|
||||
counted = [pr for pr in prs if pr["paths"] and "skip-release" not in pr["labels"]]
|
||||
urgent = [pr for pr in counted if "release-now" in pr["labels"]]
|
||||
merged = [pr["merged_at"] for pr in counted if pr.get("merged_at")]
|
||||
@@ -178,6 +248,8 @@ def decision(kind, prs, now, paused=False, force=False):
|
||||
return True, "started by hand with force"
|
||||
if paused:
|
||||
return False, "RELEASES_PAUSED is set"
|
||||
if new_line:
|
||||
return True, f"the first release of {new_line}"
|
||||
if not counted:
|
||||
return False, "no merged pull request changed what players run"
|
||||
if urgent:
|
||||
@@ -231,16 +303,39 @@ def known_issues(path=ROOT / "docs" / "known-issues.md"):
|
||||
return [line.rstrip() for line in path.read_text().splitlines() if line.startswith("- ")]
|
||||
|
||||
|
||||
def notes(kind, version, prs, issues, beta=False):
|
||||
"""(title, body) of a release; a game beta's say it is one."""
|
||||
def line_intro(kind, version, previous):
|
||||
"""The paragraph a line's first release (X.Y.0) opens with; the first after the dated tags says what changed."""
|
||||
found = semver(version, GAME_PREFIX if kind == "game" else LAUNCHER_PREFIX)
|
||||
if not found or found[2] != 0 or found[3] is not None:
|
||||
return None
|
||||
line = f"{found[0]}.{found[1]}"
|
||||
if previous and semver(previous, GAME_PREFIX if kind == "game" else LAUNCHER_PREFIX):
|
||||
return f"The first release of Horizon {line}."
|
||||
if kind == "launcher":
|
||||
return (f"The launcher is numbered with the game from now on: this is launcher {line}.0, the release after "
|
||||
f"launcher {(previous or '').removeprefix(OLD_LAUNCHER_PREFIX) or '0.16'}. Your launcher takes it by itself.")
|
||||
before = (previous or "").removeprefix(GAME_PREFIX)
|
||||
return (f"Horizon is numbered from now on: this is Horizon {line}.0" + (f", the release after {before}" if before else "")
|
||||
+ ". Releases used to be named after the day they came out; from now on they count up from "
|
||||
f"{line}.0, and the launcher's too. The launcher installs it by itself once it has updated itself. A server "
|
||||
"installed with install.sh that still says it is up to date takes it with "
|
||||
f"`horizon-server update --version {version}`.")
|
||||
|
||||
|
||||
def notes(kind, version, prs, issues, beta=False, previous=None):
|
||||
"""(title, body) of a release; a game beta's say it is one. previous: the release before it, for a line's
|
||||
first release."""
|
||||
shown = [pr for pr in prs if pr["paths"] and "skip-release" not in pr["labels"]]
|
||||
new = [pr for pr in shown if "feature" in pr["labels"]]
|
||||
fixed = [pr for pr in shown if "feature" not in pr["labels"]]
|
||||
if kind == "game":
|
||||
title = f"Horizon {version.removeprefix('v')}" + (f": {summary(new, fixed)}" if shown else "")
|
||||
title = f"Horizon {version.removeprefix(GAME_PREFIX)}" + (f": {summary(new, fixed)}" if shown else "")
|
||||
else:
|
||||
title = f"Horizon launcher {version.removeprefix('launcher-v')}"
|
||||
parts = [] if shown else ["Rebuilt from the latest main."]
|
||||
title = f"Horizon launcher {version.removeprefix(OLD_LAUNCHER_PREFIX).removeprefix(LAUNCHER_PREFIX)}"
|
||||
intro = line_intro(kind, version, previous)
|
||||
parts = [intro] if intro else []
|
||||
if not shown:
|
||||
parts.append("Rebuilt from the latest main.")
|
||||
if new:
|
||||
parts.append("### New\n" + "\n".join(map(bullet, new)))
|
||||
if fixed:
|
||||
@@ -313,7 +408,8 @@ def main():
|
||||
last, prs = gather(args.kind, head, betas=not args.stable)
|
||||
if args.command == "notes":
|
||||
version = args.tag or "unreleased"
|
||||
title, body = notes(args.kind, version, prs, known_issues(), beta=not args.stable)
|
||||
previous = last["tag_name"] if last and last["tag_name"] != version else None
|
||||
title, body = notes(args.kind, version, prs, known_issues(), beta=not args.stable, previous=previous)
|
||||
if args.out:
|
||||
args.out.mkdir(parents=True, exist_ok=True)
|
||||
(args.out / "title.txt").write_text(title + "\n")
|
||||
@@ -321,10 +417,13 @@ def main():
|
||||
print(title + "\n\n" + body)
|
||||
return 0
|
||||
|
||||
release, reason = decision(args.kind, prs, now, os.environ.get("RELEASES_PAUSED") == "1", args.force)
|
||||
tags = run("git", "tag", "--list").split()
|
||||
line = release_line()
|
||||
prefix = GAME_PREFIX if args.kind == "game" else LAUNCHER_PREFIX
|
||||
new_line = f"{line[0]}.{line[1]}" if line and first_on_line(tags, prefix, line) else None
|
||||
release, reason = decision(args.kind, prs, now, os.environ.get("RELEASES_PAUSED") == "1", args.force, new_line)
|
||||
minor = any("feature" in pr["labels"] for pr in prs if pr["paths"])
|
||||
tag = next_game_tag(tags, now.date()) if args.kind == "game" else next_launcher_tag(tags, minor)
|
||||
tag = next_game_tag(tags, now.date(), line) if args.kind == "game" else next_launcher_tag(tags, minor, line)
|
||||
result = {
|
||||
"release": release, "reason": reason, "tag": tag, "head": head,
|
||||
"last": last["tag_name"] if last else None, "last_published": last["published_at"] if last else None,
|
||||
|
||||
Reference in New Issue
Block a user