ci(gitea): split builds and retry artifact publication
This commit is contained in:
1 parent
d83f94afd5
commit
b225008476
18 files changed
+1790
-286
No files matched your search
+63
-28
@@ -8,24 +8,12 @@ import sys
|
||||
import tempfile
|
||||
import zipfile
|
||||
|
||||
from release_artifacts import AUDIT, FEED, INSTALLER, PORTABLE, app_versions, checksum_lines, validate_artifact
|
||||
from release_artifacts import AUDIT, FEED, INSTALLER, PORTABLE, METADATA, app_versions, checksum_lines, validate_artifact
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--vpk', type=Path, required=True, help='Pinned vpk executable or DLL')
|
||||
args = parser.parse_args()
|
||||
version, windows_version = app_versions(ROOT / 'pubspec.yaml')
|
||||
output = ROOT / 'dist'
|
||||
# Repeated builds must not accidentally upload a previous version's files.
|
||||
if output.exists() and any(output.iterdir()):
|
||||
raise ValueError('dist must be empty; use a clean release workspace')
|
||||
apk = ROOT / 'build/app/outputs/flutter-apk/app-production-release.apk'
|
||||
windows = ROOT / 'build/windows/x64/production/runner/Release'
|
||||
if not apk.is_file() or not (windows / 'cutdex.exe').is_file():
|
||||
raise ValueError('Both production builds are required')
|
||||
def validate_apk(apk):
|
||||
with zipfile.ZipFile(apk) as archive:
|
||||
names = archive.namelist()
|
||||
for abi in ('arm64-v8a', 'x86_64'):
|
||||
@@ -33,6 +21,9 @@ def main():
|
||||
raise ValueError(f'APK missing Flutter ABI: {abi}')
|
||||
if any(name.startswith('lib/armeabi-v7a/') for name in names):
|
||||
raise ValueError('APK must use supported 64-bit ABIs only')
|
||||
|
||||
|
||||
def package_windows(windows, vpk, windows_version):
|
||||
sys.path.insert(0, str(ROOT / 'tool/windows'))
|
||||
from check_windows_release import audit
|
||||
from windows_updates import package_app
|
||||
@@ -48,25 +39,69 @@ def main():
|
||||
with path.open('rb') as stream:
|
||||
checksums[path.relative_to(staged).as_posix()] = hashlib.file_digest(stream, 'sha256').hexdigest()
|
||||
(staged / 'checksums.json').write_text(json.dumps(checksums), encoding='utf-8')
|
||||
result = package_app(staged, releases, args.vpk, require_processing=False)
|
||||
result = package_app(staged, releases, vpk, require_processing=False)
|
||||
if result['version'] != windows_version:
|
||||
raise ValueError('Built Windows version differs from pubspec')
|
||||
contents = {f'cutdex-{version}-android.apk': apk.read_bytes(),
|
||||
AUDIT: (json.dumps(report, indent=2) + '\n').encode()}
|
||||
contents = {AUDIT: (json.dumps(report, indent=2) + '\n').encode()}
|
||||
for path in releases.iterdir():
|
||||
if path.name in {FEED, INSTALLER, PORTABLE} or path.suffix == '.nupkg':
|
||||
contents[path.name] = path.read_bytes()
|
||||
files = {name: hashlib.sha256(body).hexdigest() for name, body in contents.items()}
|
||||
manifest = {'version': version, 'files': files, 'windowsUpdateVersion': windows_version,
|
||||
'windowsPackageId': 'Cutdex', 'windowsChannel': 'win-x64',
|
||||
'androidSigning': 'debug', 'processingWorkersBundled': False}
|
||||
contents['SHA256SUMS'] = checksum_lines(files).encode()
|
||||
contents['release-manifest.json'] = (json.dumps(manifest, indent=2) + '\n').encode()
|
||||
validate_artifact(contents, version, windows_version)
|
||||
output.mkdir(exist_ok=True)
|
||||
for name, body in contents.items():
|
||||
(output / name).write_bytes(body)
|
||||
print(json.dumps(manifest, indent=2))
|
||||
return contents
|
||||
|
||||
|
||||
def assemble(contents, version, windows_version):
|
||||
files = {name: hashlib.sha256(body).hexdigest() for name, body in contents.items()}
|
||||
manifest = {'version': version, 'files': files, 'windowsUpdateVersion': windows_version,
|
||||
'windowsPackageId': 'Cutdex', 'windowsChannel': 'win-x64',
|
||||
'androidSigning': 'debug', 'processingWorkersBundled': False}
|
||||
contents['SHA256SUMS'] = checksum_lines(files).encode()
|
||||
contents['release-manifest.json'] = (json.dumps(manifest, indent=2) + '\n').encode()
|
||||
validate_artifact(contents, version, windows_version)
|
||||
return contents
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--platform', choices=['all', 'windows', 'assemble'], default='all')
|
||||
parser.add_argument('--vpk', type=Path, help='Pinned vpk executable or DLL')
|
||||
parser.add_argument('--windows-packages', type=Path, help='Previously packaged Windows artifact directory')
|
||||
args = parser.parse_args()
|
||||
if args.platform != 'assemble' and args.vpk is None:
|
||||
parser.error('--vpk is required when packaging Windows')
|
||||
if args.platform == 'assemble' and args.windows_packages is None:
|
||||
parser.error('--windows-packages is required when assembling artifacts')
|
||||
version, windows_version = app_versions(ROOT / 'pubspec.yaml')
|
||||
output = ROOT / 'dist'
|
||||
if output.exists() and any(output.iterdir()):
|
||||
raise ValueError('dist must be empty; use a clean release workspace')
|
||||
metadata = ROOT / '.build/release-metadata'
|
||||
if args.platform != 'windows' and metadata.exists() and any(metadata.iterdir()):
|
||||
raise ValueError('Release metadata output must be empty')
|
||||
apk = ROOT / 'build/app/outputs/flutter-apk/app-production-release.apk'
|
||||
windows = ROOT / 'build/windows/x64/production/runner/Release'
|
||||
if args.platform != 'windows':
|
||||
validate_apk(apk)
|
||||
if args.platform == 'assemble':
|
||||
contents = {path.name: path.read_bytes() for path in args.windows_packages.iterdir() if path.is_file()}
|
||||
if any(path.is_dir() for path in args.windows_packages.iterdir()):
|
||||
raise ValueError('Windows packages must be a flat artifact directory')
|
||||
if f'cutdex-{version}-android.apk' in contents:
|
||||
raise ValueError('Unexpected Android package in Windows artifact')
|
||||
else:
|
||||
if not (windows / 'cutdex.exe').is_file():
|
||||
raise ValueError('Production Windows build is required')
|
||||
contents = package_windows(windows, args.vpk, windows_version)
|
||||
if args.platform != 'windows':
|
||||
contents[f'cutdex-{version}-android.apk'] = apk.read_bytes()
|
||||
assemble(contents, version, windows_version)
|
||||
output.mkdir(exist_ok=True)
|
||||
for name, body in contents.items():
|
||||
(output / name).write_bytes(body)
|
||||
if args.platform != 'windows':
|
||||
metadata.mkdir(parents=True, exist_ok=True)
|
||||
for name in METADATA:
|
||||
(metadata / name).write_bytes(contents[name])
|
||||
print(json.dumps({'platform': args.platform, 'version': version, 'files': sorted(contents)}, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in new issue
Block a user