Build Android and Windows packages and promote Gitea releases
This commit is contained in:
1 parent
27e77fff39
commit
0f6097f58f
6 files changed
+257
-29
No files matched your search
@@ -0,0 +1,41 @@
|
||||
"""Package the Windows Release directory and Android production APK."""
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
|
||||
|
||||
def main():
|
||||
version = re.search(r'^version: (\S+)', (ROOT / 'pubspec.yaml').read_text(), re.M)[1].split('+')[0]
|
||||
output = ROOT / 'dist'
|
||||
output.mkdir(exist_ok=True)
|
||||
apk = ROOT / 'build/app/outputs/flutter-apk/app-production-release.apk'
|
||||
windows = ROOT / 'build/windows/x64/runner/Release'
|
||||
if not apk.is_file() or not (windows / 'cutdex.exe').is_file():
|
||||
raise ValueError('Both production builds are required')
|
||||
with zipfile.ZipFile(apk) as archive:
|
||||
names = archive.namelist()
|
||||
for abi in ('arm64-v8a', 'x86_64'):
|
||||
if f'lib/{abi}/libflutter.so' not in names:
|
||||
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')
|
||||
shutil.copyfile(apk, output / f'cutdex-{version}-android.apk')
|
||||
package = output / f'cutdex-{version}-windows-x64.zip'
|
||||
with zipfile.ZipFile(package, 'w', compression=zipfile.ZIP_DEFLATED) as archive:
|
||||
for path in sorted(windows.rglob('*')):
|
||||
if path.is_file() and path.suffix.lower() not in ('.pdb', '.lib', '.exp'):
|
||||
archive.write(path, f'cutdex-{version}/' + path.relative_to(windows).as_posix())
|
||||
files = sorted(output.glob('*.apk')) + sorted(output.glob('*.zip'))
|
||||
manifest = {path.name: hashlib.file_digest(path.open('rb'), 'sha256').hexdigest() for path in files}
|
||||
(output / 'SHA256SUMS').write_text(''.join(f'{digest} {name}\n' for name, digest in manifest.items()))
|
||||
(output / 'release-manifest.json').write_text(json.dumps({'version': version, 'files': manifest, 'androidSigning': 'debug', 'processingWorkersBundled': False}, indent=2) + '\n')
|
||||
print(json.dumps(manifest, indent=2))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user