refactor(build): unify SDK configuration and release tooling

Pin Flutter with FVM and share local environment loading across IDE, Python, and Dart entrypoints. Keep CI on the verified preinstalled SDK and skip local overrides.

Extract common build presets, process execution, and file hashing. Propagate project roots through SDK selection and release commands, and migrate macOS release, signing, and DMG orchestration to Python.

Reuse local check suites in CI, support Android source overrides, and update documentation and regression tests.
This commit is contained in:
lingjhf committed 2026-10-06 23:34:15 +08:00
1 parent a13a54d5ec
commit 0343e2f723
57 files changed
+1858 -375

No files matched your search

+40 -1
View File
@@ -2,6 +2,7 @@
import base64
from pathlib import Path
import plistlib
import subprocess
import tempfile
import unittest
from unittest.mock import patch
@@ -51,6 +52,44 @@ class UpdateConfigurationTests(unittest.TestCase):
class PublicationVersionTests(unittest.TestCase):
def test_publication_writes_signed_archive_and_preserves_feed_on_tool_failure(self):
for failure in (False, True):
with self.subTest(failure=failure), tempfile.TemporaryDirectory() as directory:
output = Path(directory)
feed = output / 'appcast.xml'
original = (f'<rss xmlns:sparkle="{SPARKLE}"><channel><item>'
'<sparkle:version>1</sparkle:version>'
'</item></channel></rss>').encode()
feed.write_bytes(original)
generated = (f'<rss xmlns:sparkle="{SPARKLE}"><channel><item>'
'<sparkle:version>2</sparkle:version>'
'<enclosure sparkle:edSignature="test-signature"/>'
'</item></channel></rss>').encode()
def generate(command, *, cwd, check):
self.assertEqual(cwd, Path.cwd())
self.assertTrue(check)
if command[0] == 'ditto':
Path(command[-1]).write_bytes(b'archive')
elif failure:
raise subprocess.CalledProcessError(19, command)
else:
Path(command[command.index('-o') + 1]).write_bytes(generated)
with patch('macos_updates.validate_app', return_value={'CFBundleVersion': '2'}), \
patch('macos_updates.run', side_effect=generate):
if failure:
with self.assertRaises(subprocess.CalledProcessError) as raised:
publish(Path('app'), output, 'https://example.com/', Path('tools'))
self.assertEqual(raised.exception.returncode, 19)
self.assertEqual(feed.read_bytes(), original)
self.assertEqual(list(output.glob('*.zip')), [])
else:
archive = publish(Path('app'), output, 'https://example.com/', Path('tools'))
self.assertEqual(archive.read_bytes(), b'archive')
self.assertEqual(feed.read_bytes(), generated)
self.assertFalse((output / 'appcast.xml.pending').exists())
def test_older_or_equivalent_build_cannot_replace_current_feed(self):
for current, candidate in [('900002', '900001'), ('2', '2.0'), ('2.10', '2.9')]:
with self.subTest(current=current, candidate=candidate), tempfile.TemporaryDirectory() as directory:
@@ -70,7 +109,7 @@ class PublicationVersionTests(unittest.TestCase):
'<enclosure sparkle:edSignature="test-signature"/>'
'</item></channel></rss>')
with patch('macos_updates.validate_app', return_value={'CFBundleVersion': candidate}), \
patch('macos_updates.subprocess.run', side_effect=generate) as run:
patch('macos_updates.run', side_effect=generate) as run:
with self.assertRaisesRegex(ValueError, 'newer'):
publish(Path('app'), output, 'https://example.com/', Path('tools'))
run.assert_not_called()