fix: reuse immutable appcast assets during feed retries

This commit is contained in:
Kevin Yue committed 2026-10-23 01:03:10 +08:00
1 parent 3a8080eb2f
commit 4b61c84c37
2 files changed
+57 -1

No files matched your search

+2 -1
View File
@@ -472,7 +472,7 @@ jobs:
archive_url="https://github.com/$REPOSITORY/releases/download/$RELEASE_TAG/${{ steps.archive.outputs.name }}"
if [[ "$CHANNEL" == "stable" ]] && \
gh release view "$RELEASE_TAG" --repo "$REPOSITORY" --json assets \
--jq '.assets[].name' | grep -Fxq appcast.xml; then
--jq '.assets[].name' | grep -Fx appcast.xml >/dev/null; then
existing="$RUNNER_TEMP/existing-release-appcast.xml"
gh release download "$RELEASE_TAG" --repo "$REPOSITORY" \
--pattern appcast.xml --output "$existing"
@@ -482,6 +482,7 @@ jobs:
--short-version "${{ steps.bundle.outputs.short_version }}" \
--channel "$CHANNEL" \
--archive-url "$archive_url"
cp "$existing" "$appcast"
else
if [[ "$CHANNEL" == "snapshot" ]]; then
RELEASE_REPOSITORY="$REPOSITORY" \
@@ -1,8 +1,14 @@
import os
import shutil
import subprocess
import sys
import tempfile
import textwrap
import unittest
from pathlib import Path
from test_private_ci import run_block
REPOSITORY = "yuezk/GlobalProtect-openconnect"
SCRIPT = Path(__file__).parents[1] / "validate-macos-appcast.py"
@@ -112,5 +118,54 @@ class ValidateMacosAppcastTests(unittest.TestCase):
self.assertIn("unexpected update archive URL", result.stderr)
class PublishMacosAppcastTests(unittest.TestCase):
def test_retry_reuses_existing_stable_appcast_without_uploading(self):
archive = f"https://github.com/{REPOSITORY}/releases/download/v2.6.4/GPConnect_2.6.4_arm64.zip"
existing = appcast(item("806.1", "2.6.4", archive))
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "updates").mkdir()
(root / "updates/appcast.xml").write_text("newly generated candidate")
(root / "existing.xml").write_text(existing)
(root / "scripts").mkdir()
shutil.copy(SCRIPT, root / "scripts/validate-macos-appcast.py")
(root / "python3").symlink_to(sys.executable)
gh = root / "gh"
gh.write_text(f"#!{sys.executable}\n" + textwrap.dedent('''\
import os, shutil, signal, sys
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
if sys.argv[1:3] == ['release', 'view']:
print('appcast.xml', flush=True)
for number in range(10000):
print(f'other-asset-{number}')
elif sys.argv[1:3] == ['release', 'download']:
shutil.copy(os.environ['EXISTING_APPCAST'],
sys.argv[sys.argv.index('--output') + 1])
else:
sys.exit(99)
'''))
gh.chmod(0o755)
uploader = root / "gp-release/scripts/upload-release-assets.sh"
uploader.parent.mkdir(parents=True)
uploader.write_text("#!/bin/sh\ntouch upload-attempted\nexit 7\n")
uploader.chmod(0o755)
command = run_block('.github/workflows/publish-update-feeds.yaml', 'Publish appcast')
for expression, value in {
'${{ steps.archive.outputs.name }}': 'GPConnect_2.6.4_arm64.zip',
'${{ steps.bundle.outputs.version }}': '806.1',
'${{ steps.bundle.outputs.short_version }}': '2.6.4',
}.items():
command = command.replace(expression, value)
result = subprocess.run(['bash', '-e', '-o', 'pipefail', '-c', command], cwd=root,
env=dict(os.environ, PATH=f'{root}:{os.environ["PATH"]}',
RUNNER_TEMP=str(root), CHANNEL='stable',
RELEASE_TAG='v2.6.4', REPOSITORY=REPOSITORY,
EXISTING_APPCAST=str(root / 'existing.xml')),
capture_output=True, text=True)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertFalse((root / 'upload-attempted').exists())
self.assertEqual((root / 'updates/appcast.xml').read_text(), existing)
if __name__ == "__main__":
unittest.main()