Skip to content

Commit 948d941

Browse files
committed
fix(ci): normalize windows portable naming
1 parent 208b5e7 commit 948d941

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

scripts/ci/package_windows_portable.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
WINDOWS_LEGACY_INSTALLER_RE = re.compile(
2424
r"(?P<name>.+?)_(?P<version>.+?)_(?P<arch>x64|amd64|arm64|aarch64)-setup\.exe$"
2525
)
26+
LEGACY_NIGHTLY_VERSION_RE = re.compile(
27+
rf"^(?P<version>.+?)-nightly[._-](?P<date>[0-9]{{8}})[._-](?P<sha>{SHORT_SHA_PATTERN})$"
28+
)
2629

2730
PORTABLE_README_NAME = "README-portable.txt"
2831
PORTABLE_README_TEXT = """AstrBot Windows portable package
@@ -119,7 +122,12 @@ def installer_to_portable_name(installer_name: str) -> str:
119122
name = legacy_match.group("name")
120123
version = legacy_match.group("version")
121124
arch = normalize_arch(legacy_match.group("arch"))
122-
return f"{name}_{version}_windows_{arch}_portable.zip"
125+
nightly_suffix = ""
126+
nightly_match = LEGACY_NIGHTLY_VERSION_RE.fullmatch(version)
127+
if nightly_match:
128+
version = nightly_match.group("version")
129+
nightly_suffix = f"_nightly_{nightly_match.group('sha')}"
130+
return f"{name}_{version}_windows_{arch}_portable{nightly_suffix}.zip"
123131

124132
raise ValueError(
125133
"Unexpected Windows installer name: "
@@ -203,9 +211,10 @@ def populate_portable_root(
203211
) -> None:
204212
release_dir = resolve_release_dir(bundle_dir)
205213
main_executable_path = resolve_main_executable_path(bundle_dir, project_config)
214+
portable_executable_name = f"{project_config.product_name}.exe"
206215

207216
destination_root.mkdir(parents=True, exist_ok=True)
208-
shutil.copy2(main_executable_path, destination_root / main_executable_path.name)
217+
shutil.copy2(main_executable_path, destination_root / portable_executable_name)
209218

210219
webview_loader = release_dir / "WebView2Loader.dll"
211220
if webview_loader.is_file():

scripts/ci/test_package_windows_portable.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ def test_installer_to_portable_name_accepts_canonical_nightly_windows_name(self)
2727
"AstrBot_4.29.0_windows_amd64_portable_nightly_deadbeef.zip",
2828
)
2929

30+
def test_installer_to_portable_name_normalizes_legacy_nightly_windows_name(self):
31+
self.assertEqual(
32+
MODULE.installer_to_portable_name(
33+
"AstrBot_4.29.0-nightly.20260401.deadbeef_aarch64-setup.exe"
34+
),
35+
"AstrBot_4.29.0_windows_arm64_portable_nightly_deadbeef.zip",
36+
)
37+
3038
def test_installer_to_portable_name_rejects_noncanonical_nightly_suffix_length(
3139
self,
3240
):
@@ -299,7 +307,8 @@ def test_populate_portable_root_copies_release_bundle_contents(self):
299307
project_config=MODULE.load_project_config_from(script_path),
300308
)
301309

302-
self.assertTrue((destination_root / "astrbot-desktop-tauri.exe").is_file())
310+
self.assertTrue((destination_root / "AstrBot.exe").is_file())
311+
self.assertFalse((destination_root / "astrbot-desktop-tauri.exe").exists())
303312
self.assertTrue((destination_root / "WebView2Loader.dll").is_file())
304313
self.assertTrue(
305314
(

0 commit comments

Comments
 (0)