forked from 1b-agent/opencadstudio-upstream
fix(release): support fix releases on top of a weekly one
`v2026.40.1` matched neither the weekly pattern nor plain semver (2026 is past the MSI major limit), so a fix release could not be built. Weekly tags now take an optional patch: Cargo 2026.40.1, MSI 26.40.1, display 2026.40.1 (week zero-padded, as build.rs and the update check expect). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
47eef134cb
commit
a3bcded498
4 files changed
+29
-15
No files matched your search
+9
-6
@@ -21,12 +21,14 @@ def gh(*args):
|
||||
|
||||
def versions(tag):
|
||||
version = tag.removeprefix("v")
|
||||
weekly = re.fullmatch(r"(20\d{2})\.(\d{2})", version)
|
||||
# `2026.40` is the weekly release; `2026.40.1` a fix release on top of it.
|
||||
weekly = re.fullmatch(r"(20\d{2})\.(\d{2})(?:\.([1-9]\d*))?", version)
|
||||
if weekly:
|
||||
year, week = map(int, weekly.groups())
|
||||
year, week = int(weekly[1]), int(weekly[2])
|
||||
patch = int(weekly[3] or 0)
|
||||
date.fromisocalendar(year, week, 1)
|
||||
cargo = f"{year}.{week}.0"
|
||||
msi = f"{year - 2000}.{week}.0"
|
||||
cargo = f"{year}.{week}.{patch}"
|
||||
msi = f"{year - 2000}.{week}.{patch}"
|
||||
elif re.fullmatch(r"(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)", version):
|
||||
cargo = msi = version
|
||||
major, minor, patch = map(int, version.split("."))
|
||||
@@ -43,8 +45,9 @@ def cargo_version():
|
||||
|
||||
def display_version(cargo):
|
||||
year, week, patch = cargo.split(".")
|
||||
if len(year) == 4 and year.startswith("20") and patch == "0":
|
||||
return versions(f"{year}.{int(week):02}")["version"]
|
||||
if len(year) == 4 and year.startswith("20"):
|
||||
weekly = f"{year}.{int(week):02}"
|
||||
return versions(weekly if patch == "0" else f"{weekly}.{patch}")["version"]
|
||||
return cargo
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class ReleaseTests(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as temp:
|
||||
binary = str(Path(temp) / "build-script")
|
||||
subprocess.run(["rustc", str(Path(__file__).resolve().parents[1] / "build.rs"), "-o", binary], check=True)
|
||||
for cargo in ("0.9.8", "2026.9.0", "2026.35.0", "2026.53.0", "2027.1.0"):
|
||||
for cargo in ("0.9.8", "2026.9.0", "2026.35.0", "2026.53.0", "2027.1.0", "2026.40.1", "2026.5.2"):
|
||||
result = subprocess.check_output([binary], text=True, env={**os.environ, "CARGO_PKG_VERSION": cargo})
|
||||
self.assertIn(f"cargo:rustc-env=OCS_APP_VERSION={release.display_version(cargo)}\n", result)
|
||||
|
||||
@@ -61,6 +61,10 @@ class ReleaseTests(unittest.TestCase):
|
||||
self.assertEqual(release.versions("2026.09")["cargo"], "2026.9.0")
|
||||
self.assertEqual(release.display_version("2026.9.0"), "2026.09")
|
||||
self.assertEqual(release.display_version("0.9.8"), "0.9.8")
|
||||
self.assertEqual(release.versions("v2026.40.1"), {
|
||||
"version": "2026.40.1", "cargo": "2026.40.1", "msi": "26.40.1", "tag": "v2026.40.1",
|
||||
})
|
||||
self.assertEqual(release.display_version("2026.5.2"), "2026.05.2")
|
||||
self.assertEqual(datetime(2027, 1, 3, tzinfo=timezone.utc).strftime("v%G.%V"), "v2026.53")
|
||||
for value in ("2026.00", "2026.54", "2027.53", "2026.9", "2026.35.0", "bad", "0.09.8"):
|
||||
with self.assertRaises(ValueError, msg=value):
|
||||
|
||||
Reference in new issue
Block a user