refactor(build): 统一本地与 CI 构建入口及平台发布工具 (#9)
Gitea CI / Check code and tests (push) Successful in 7m38s
Gitea CI / Build Android APK (push) Successful in 6m20s
Gitea CI / Audit and package Windows x64 (push) Canceled after 0s
Gitea CI / Assemble and validate CI artifacts (push) Canceled after 0s
Gitea CI / Gitea CI passed (push) Canceled after 0s
Gitea CI / Build Windows x64 app (push) Canceled after 14m42s

This commit was merged in pull request #9.
This commit is contained in:
lingjhf committed 2026-10-06 16:14:42 +00:00
1 parent a13a54d5ec
commit 4a759d81a6
61 files changed
+1913 -388

No files matched your search

+19 -27
View File
@@ -1,27 +1,28 @@
"""Package audited Windows releases with Velopack, or serve a loopback test feed."""
import argparse
from functools import partial
import hashlib
from http.server import SimpleHTTPRequestHandler, ThreadingHTTPServer
import json
from pathlib import Path
import re
import subprocess
import sys
from urllib.parse import urljoin, urlparse
from urllib.request import url2pathname
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from common.files import file_sha256
from common.process import ROOT, cli, run
from check_windows_release import audit
from update_versions import numeric_version, update_version
ROOT = Path(__file__).resolve().parents[2]
SDK_VERSION = '1.2.161'
def resolved_deskup():
config = ROOT / '.dart_tool/package_config.json'
if not config.is_file():
raise ValueError('Run flutter pub get before using Windows update tools')
raise ValueError('Run fvm dart tool/flutter_local.dart pub get before using Windows update tools')
packages = json.loads(config.read_text(encoding='utf-8'))['packages']
package = next(item for item in packages if item['name'] == 'deskup')
uri = urlparse(urljoin(config.as_uri(), package['rootUri']))
@@ -48,7 +49,7 @@ def vpk_command(path):
def check_tool(command):
result = subprocess.run(command + ['--help'], capture_output=True, text=True,
result = run(command + ['--help'], cwd=Path.cwd(), capture_output=True, text=True,
encoding='utf-8', errors='replace', check=True, timeout=30)
if not re.search(rf'(?<![\d.]){re.escape(SDK_VERSION)}(?![\d.])', result.stdout + result.stderr):
raise ValueError(f'Use vpk {SDK_VERSION} to match the native SDK')
@@ -56,11 +57,11 @@ def check_tool(command):
def pack_release(command, *, app, output, package_id, version, title):
numeric_version(version)
subprocess.run(command + ['pack', '--packId', package_id, '--packVersion', version,
run(command + ['pack', '--packId', package_id, '--packVersion', version,
'--packDir', str(app), '--mainExe', 'cutdex.exe',
'--packTitle', title, '--runtime', 'win-x64',
'--channel', 'win-x64', '--outputDir', str(output),
'--delta', 'none'], check=True)
'--delta', 'none'], cwd=Path.cwd(), check=True)
def file_version(app):
@@ -103,9 +104,8 @@ def verify_manifest(app):
file = candidate.resolve()
if not file.is_relative_to(app) or candidate.is_symlink():
raise ValueError(f'Invalid manifest path: {name}')
with file.open('rb') as stream:
if hashlib.file_digest(stream, 'sha256').hexdigest().lower() != expected.lower():
raise ValueError(f'Release checksum mismatch: {name}')
if file_sha256(file).lower() != expected.lower():
raise ValueError(f'Release checksum mismatch: {name}')
def package_app(app, output, vpk, *, development=False, require_processing=True):
@@ -159,23 +159,15 @@ def main():
server.add_argument('--directory', type=Path, required=True)
server.add_argument('--port', type=int, default=8765)
args = parser.parse_args()
try:
if args.command == 'pack':
verify_sdk_version()
print(json.dumps(package_app(args.app, args.output, args.vpk,
development=args.development)))
elif args.command == 'verify-sdk':
print(f'Velopack SDK {verify_sdk_version()} verified')
else:
serve(args.directory, args.port)
except KeyboardInterrupt:
return
except (ValueError, OSError) as error:
print(str(error), file=sys.stderr)
raise SystemExit(1) from error
except subprocess.CalledProcessError as error:
raise SystemExit(error.returncode) from error
if args.command == 'pack':
verify_sdk_version()
print(json.dumps(package_app(args.app, args.output, args.vpk,
development=args.development)))
elif args.command == 'verify-sdk':
print(f'Velopack SDK {verify_sdk_version()} verified')
else:
serve(args.directory, args.port)
if __name__ == '__main__':
main()
sys.exit(cli(main))