From 1305d37fae3ea1390ec837ce68797b12940828c9 Mon Sep 17 00:00:00 2001 From: faumaray Date: Tue, 28 Jul 2026 21:41:55 +0300 Subject: [PATCH] Release: enforce root version across component feeds --- .gitea/RELEASING.md | 14 +++++- .gitea/workflows/release.yml | 13 +++++ EchoionWeb/frontend/src/lib/updates.test.ts | 13 +++++ scripts/gitea_release.py | 15 ++++-- scripts/tests/test_aggregate_update_feed.py | 38 ++++++++++++++- scripts/tests/test_gitea_release.py | 53 +++++++++++++++++++++ 6 files changed, 139 insertions(+), 7 deletions(-) diff --git a/.gitea/RELEASING.md b/.gitea/RELEASING.md index 3f452d6..0e7bf94 100644 --- a/.gitea/RELEASING.md +++ b/.gitea/RELEASING.md @@ -93,7 +93,15 @@ git add components.lock.json uncommitted source. `--update` moves existing clean component checkouts to the locked revisions. Product version changes are separate: edit only `project(Echoion VERSION ...)` in root `CMakeLists.txt`; orchestrated component -builds and release overrides inherit that value. +builds and release overrides inherit that value. A stable or beta release tag +must have the same numeric base as this CMake version, so `v1.2.3` and +`v1.2.3-rc.1` both require `project(Echoion VERSION 1.2.3 ...)`. The release +workflow rejects mismatches before building. + +Nightlies use the newer of the root CMake version and the next patch after the +latest published release. This prevents a stale CMake value from producing a +version rollback while still allowing a single CMake edit to move nightlies to +a newer minor or major release line. Create an orphan `release-feed` branch containing a tracked `feeds/` directory, then protect it so only the release bot can push. Protect the `v*` @@ -121,7 +129,9 @@ installation has a signed official source without operator-side duplication. ## Stable and beta releases Create an annotated SSH-signed tag. A version without a prerelease suffix goes -to `stable`; any strict SemVer prerelease goes to `beta`. +to `stable`; any strict SemVer prerelease goes to `beta`. First set the product +version in the root `CMakeLists.txt`, commit it, and use the same numeric base +for the tag: ```bash git config gpg.format ssh diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 8896eea..4a82383 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -125,6 +125,7 @@ jobs: shell: bash env: TAG: ${{ gitea.ref_name }} + API_URL: ${{ gitea.api_url }} SERVER_URL: ${{ gitea.server_url }} REPOSITORY: ${{ gitea.repository }} run: | @@ -132,6 +133,18 @@ jobs: version=${TAG#v} test "$version" != "$TAG" python3 scripts/validate-semver.py "$version" + project_version=$( + python3 scripts/gitea_release.py \ + --api-url "$API_URL" \ + cmake-project-version \ + --cmake-file CMakeLists.txt + ) + tag_base=${version%%[-+]*} + if [[ "$tag_base" != "$project_version" ]]; then + printf 'release tag %s does not match root CMake project version %s\n' \ + "$TAG" "$project_version" >&2 + exit 1 + fi channel=stable prerelease=false if [[ "$version" == *-* ]]; then diff --git a/EchoionWeb/frontend/src/lib/updates.test.ts b/EchoionWeb/frontend/src/lib/updates.test.ts index b587600..a9dbe55 100644 --- a/EchoionWeb/frontend/src/lib/updates.test.ts +++ b/EchoionWeb/frontend/src/lib/updates.test.ts @@ -74,11 +74,24 @@ describe('update payload normalization', () => { signed: false, requiresRestart: true, }); + expect(status.components.core).toMatchObject({ + component: 'core', + currentVersion: '4.0.0', + state: 'healthy', + }); + expect(status.components.plugins).toMatchObject({ + component: 'plugins', + state: 'current', + }); expect(status.plugins[0]).toMatchObject({ id: 'weather', managed: true, currentVersion: '2.0.0', }); + expect(status.plugins[0].candidate).toMatchObject({ + version: '2.1.0', + signed: true, + }); expect(status.history).toHaveLength(1); }); diff --git a/scripts/gitea_release.py b/scripts/gitea_release.py index 30922cf..5fde6a8 100755 --- a/scripts/gitea_release.py +++ b/scripts/gitea_release.py @@ -672,11 +672,12 @@ def derive_nightly_version(arguments: argparse.Namespace, api: GiteaApi) -> None (int(match.group(1)), int(match.group(2)), int(match.group(3))) ) + cmake_version = cmake_project_version(arguments.cmake_file) + next_released_version = cmake_version if released_versions: major, minor, patch = max(released_versions) - patch += 1 - else: - major, minor, patch = cmake_project_version(arguments.cmake_file) + next_released_version = major, minor, patch + 1 + major, minor, patch = max(cmake_version, next_released_version) version = ( f"{major}.{minor}.{patch}-nightly." f"{arguments.date_id}.{arguments.run_number}" @@ -726,11 +727,19 @@ def parser() -> argparse.ArgumentParser: nightly_version_parser.add_argument("--cmake-file", type=Path, required=True) nightly_version_parser.add_argument("--date-id", required=True) nightly_version_parser.add_argument("--run-number", required=True) + + project_version_parser = subparsers.add_parser("cmake-project-version") + project_version_parser.add_argument( + "--cmake-file", type=Path, required=True + ) return result def main() -> None: arguments = parser().parse_args() + if arguments.command == "cmake-project-version": + print(".".join(map(str, cmake_project_version(arguments.cmake_file)))) + return if arguments.command == "prune-nightlies" and arguments.keep < 1: fail("--keep must be positive") if arguments.command == "prune-nightlies": diff --git a/scripts/tests/test_aggregate_update_feed.py b/scripts/tests/test_aggregate_update_feed.py index 01a56a3..6631164 100755 --- a/scripts/tests/test_aggregate_update_feed.py +++ b/scripts/tests/test_aggregate_update_feed.py @@ -181,6 +181,8 @@ class AggregateUpdateFeedTest(unittest.TestCase): def test_multiple_component_payloads_are_signed_together(self) -> None: runtime_payload = self.root / "runtime.json" core_payload = self.root / "core.json" + internal_plugin_payload = self.root / "internal-plugin.json" + external_plugin_payload = self.root / "external-plugin.json" runtime_release = release("1.2.3", "stable") core_release = { **release("1.2.3", "stable"), @@ -189,8 +191,28 @@ class AggregateUpdateFeedTest(unittest.TestCase): "packageType": "shared-library", } core_release.pop("releaseManifestSha256") + internal_plugin_release = { + **core_release, + "component": "plugin", + "artifactId": "url-shortener-internal", + "url": ( + "https://updates.example.invalid/" + "url-shortener-internal-1.2.3.so" + ), + } + external_plugin_release = { + **core_release, + "component": "plugin", + "artifactId": "url-shortener-external", + "url": ( + "https://updates.example.invalid/" + "url-shortener-external-1.2.3.so" + ), + } payload(runtime_payload, [runtime_release], 100) payload(core_payload, [core_release], 100) + payload(internal_plugin_payload, [internal_plugin_release], 100) + payload(external_plugin_payload, [external_plugin_release], 100) output = self.root / "components-output.json" self.run_script( @@ -199,11 +221,23 @@ class AggregateUpdateFeedTest(unittest.TestCase): self.root / "components-envelope.json", "--new-payload", os.fspath(core_payload), + "--new-payload", + os.fspath(internal_plugin_payload), + "--new-payload", + os.fspath(external_plugin_payload), ) releases = json.loads(output.read_text(encoding="utf-8"))["releases"] self.assertEqual( - {(item["component"], item["version"]) for item in releases}, - {("runtime", "1.2.3"), ("core", "1.2.3")}, + { + (item["component"], item["artifactId"], item["version"]) + for item in releases + }, + { + ("runtime", "", "1.2.3"), + ("core", "", "1.2.3"), + ("plugin", "url-shortener-internal", "1.2.3"), + ("plugin", "url-shortener-external", "1.2.3"), + }, ) def test_tampered_existing_envelope_is_rejected(self) -> None: diff --git a/scripts/tests/test_gitea_release.py b/scripts/tests/test_gitea_release.py index 9499a9e..82e5369 100755 --- a/scripts/tests/test_gitea_release.py +++ b/scripts/tests/test_gitea_release.py @@ -679,6 +679,59 @@ class GiteaReleaseTest(unittest.TestCase): "3.2.1-nightly.20260727.18", ) + def test_nightly_version_prefers_newer_root_cmake_version(self) -> None: + cmake_file = Path(self.temporary.name, "CMakeLists.txt") + cmake_file.write_text( + "project(Echoion VERSION 3.0.0 LANGUAGES CXX)\n", + encoding="utf-8", + ) + self.server.state.releases[1] = { + "id": 1, + "tag_name": "v2.4.0", + "target_commitish": "0123456789abcdef0123456789abcdef01234567", + "name": "Echoion 2.4.0", + "body": "", + "prerelease": False, + "draft": False, + "assets": [], + "created_at": "2026-07-26T00:00:00Z", + "published_at": "2026-07-26T00:00:00Z", + } + + completed = self.run_script( + "derive-nightly-version", + "--owner", + "Void", + "--repo", + "Echoion", + "--cmake-file", + os.fspath(cmake_file), + "--date-id", + "20260728", + "--run-number", + "19", + ) + + self.assertEqual( + completed.stdout.strip(), + "3.0.0-nightly.20260728.19", + ) + + def test_root_cmake_project_version_command(self) -> None: + cmake_file = Path(self.temporary.name, "CMakeLists.txt") + cmake_file.write_text( + "project(Echoion VERSION 4.5.6 LANGUAGES CXX)\n", + encoding="utf-8", + ) + + completed = self.run_script( + "cmake-project-version", + "--cmake-file", + os.fspath(cmake_file), + ) + + self.assertEqual(completed.stdout.strip(), "4.5.6") + if __name__ == "__main__": unittest.main()