From c9a0eae23c1737e6528dc61654f5fc3f7606a55f Mon Sep 17 00:00:00 2001 From: Waozi Date: Thu, 29 Oct 2026 12:56:34 -0300 Subject: [PATCH] Bump versions only when a release is made Between releases every change goes under one Unreleased section of CHANGELOG.md and of each app's changelog; App packages already waits for the next version. The version check accepts that leading section, and the version test fixture copies the release notes script update_version.sh runs. --- AGENTS.md | 5 ++++- scripts/check-version.py | 3 +++ tests/version_test.py | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 768fcd8f7..9fecff960 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,10 @@ - Practice media (pictures, course data, recordings) lives in the `practices` package (waozixyz/practices), not under `assets/`. Commit media there, then update the lock here. -- Add the numeric release to `CHANGELOG.md`, then run `./update_version.sh`. +- Bump versions only for a release actually being made. Until then, note + every change under one `## [Unreleased]` section of `CHANGELOG.md` (and of + `apps//CHANGELOG.md`); App packages waits for the next version. At + release, number that section, then run `./update_version.sh`. The canonical macros are `APP_VERSION_STRING`, `APP_VERSION_MAJOR`, `APP_VERSION_MINOR`, and `APP_VERSION_PATCH`; do not create aliases. Only the GitHub Actions release workflow creates or pushes release tags. diff --git a/scripts/check-version.py b/scripts/check-version.py index a51b13246..5d827b381 100644 --- a/scripts/check-version.py +++ b/scripts/check-version.py @@ -32,6 +32,9 @@ def validate(root, structure_only=False): return (root / path).read_text(encoding="utf-8") headings = re.findall(r"^## \[(.*?)\].*$", read("CHANGELOG.md"), re.MULTILINE) + # Changes collect under one Unreleased section until a release numbers it. + if headings[:1] == ["Unreleased"]: + headings = headings[1:] if not headings or not re.fullmatch(VERSION_PATTERN, headings[0]): raise ValueError("CHANGELOG.md: first release must have a numeric X.Y.Z version") version = headings[0] diff --git a/tests/version_test.py b/tests/version_test.py index 18e624eb7..c90877152 100644 --- a/tests/version_test.py +++ b/tests/version_test.py @@ -26,6 +26,7 @@ class VersionTest(unittest.TestCase): "apps/lumi/CHANGELOG.md", "apps/leaderboard/CHANGELOG.md", "src/apps/versions.zi", "scripts/update-package-version.py", "scripts/generate-package-versions.py", + "scripts/release_notes.py", "src/core/version.h", "src/core/version.zi", "src/storage/sync_result.zi", "droid/app/build.gradle", "windows/inbe.rc", @@ -177,6 +178,16 @@ class VersionTest(unittest.TestCase): result = subprocess.run(["sh", str(script), invalid], capture_output=True, check=False) self.assertNotEqual(result.returncode, 0) + def test_unreleased_changes_keep_the_released_version(self): + code = re.search(r"versionCode (\d+)", self.read("droid/app/build.gradle"))[1] + name = "CHANGELOG.md" + self.write(name, self.read(name).replace( + "# Changelog\n", "# Changelog\n\n## [Unreleased]\n\n- A change waiting for the next release.\n", 1)) + self.assertEqual(self.check("--print-version").stdout, f"{self.version}\n") + subprocess.run(["bash", str(self.root / "update_version.sh")], capture_output=True, text=True, check=True) + self.assertEqual(self.check("--print-version").stdout, f"{self.version}\n") + self.assertIn(f"versionCode {code}", self.read("droid/app/build.gradle")) + def test_updater_bumps_once_and_is_idempotent(self): initial_code = int(re.search(r"versionCode (\d+)", self.read("droid/app/build.gradle"))[1]) name = "CHANGELOG.md"