Kaleido/scripts/package_release.py
Elijah 6a53196748
All checks were successful
Validate and publish Kaleido / android (push) Successful in 2m23s
Release 0.1.5 with a reliable Settings update flow
The update button no longer disappears while downloading, so focus can't
be lost and the remote no longer jumps to Home from Settings. It shows
download progress, offers Install again after a cancelled installer, and
restores focus on return. Settings scrolls only as far as needed, shows
just the new version's notes above the buttons, and focused primary
buttons now stand apart from unfocused ones. Release bodies and the
manifest carry only that version's changelog section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 14:00:32 -07:00

18 lines
1.3 KiB
Python

"""Stage a locally signed APK for Git distribution and tag-triggered Forgejo releases."""
import hashlib, json, pathlib, re, shutil, subprocess
ROOT=pathlib.Path(__file__).resolve().parents[1]
version=dict(l.split('=',1) for l in (ROOT/'version.properties').read_text().splitlines() if '=' in l)
apk=ROOT/'app/build/outputs/apk/release/app-release.apk'
if not apk.exists():raise SystemExit('Run Build.ps1 -Release first.')
out=ROOT/'distribution';out.mkdir(exist_ok=True)
shutil.copyfile(apk,out/'Kaleido.apk')
digest=hashlib.sha256(apk.read_bytes()).hexdigest()
(out/'Kaleido.apk.sha256').write_text(digest+' Kaleido.apk\n')
repo='https://git.elijahkuntz.com/Elijah/Kaleido'
tag='v'+version['versionName']
# Only this version's section, matching the release body the app shows as notes.
changelog=(ROOT/'CHANGELOG.md').read_text() if (ROOT/'CHANGELOG.md').exists() else ''
section=re.search(r'^## v?'+re.escape(version['versionName'])+r'[ \t]*$(.*?)(?=^## |\Z)',changelog,re.M|re.S)
manifest={'version':version['versionName'],'versionCode':int(version['versionCode']),'url':repo+'/raw/tag/'+tag+'/distribution/Kaleido.apk','checksumUrl':repo+'/raw/tag/'+tag+'/distribution/Kaleido.apk.sha256','notes':section.group(1).strip() if section else ''}
(out/'latest.json').write_text(json.dumps(manifest,indent=2)+'\n')
print('Packaged',tag,'SHA-256',digest)