diff --git a/README.md b/README.md index c9a57f7..6f43287 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ NavFrame is an experimental Android navigation app that renders its own 480×240 The owner has confirmed static and synthetic NavFrame frames on a Xiaomi 11 Lite 5G NE running Android 14 and a 2026 Yamaha MT-07, and the bundled Asturias map working offline on the phone. On 2026-10-12, the owner reported that the latest version displayed the map on the TFT for about 20 minutes, then showed `Mapa no disponible` in La Corredoria (Oviedo) for the rest of the trip while the phone map continued working. An offline map was installed. The exact installed build, diagnostic code and background state were not recorded; the cause is under investigation. This establishes a successful map display followed by a persistent failure, not sustained TFT reliability. -The current checkout is version 0.13.7. The 0.13 series adds voice/routing language selection for Spanish, English, German, French, and Italian, plus a system-language option; unsupported system locales resolve to English. Speech still depends on the Android TextToSpeech engine and its installed voice data. The app includes offline map and place data for Asturias, plus installable regional packages. Worldwide regions can be discovered and built on demand through the [regional package workflow](docs/GLOBAL_OFFLINE.md); this is not complete worldwide coverage. Installed packages currently provide map and local place/camera data. Offline route calculation, global camera completeness, and complete worldwide font coverage are not provided. +The current checkout is version 0.14.6. The 0.13 series adds voice/routing language selection for Spanish, English, German, French, and Italian, plus a system-language option; unsupported system locales resolve to English. Speech still depends on the Android TextToSpeech engine and its installed voice data. The app includes offline map and place data for Asturias, plus installable regional packages. Worldwide regions can be discovered and built on demand through the [regional package workflow](docs/GLOBAL_OFFLINE.md); this is not complete worldwide coverage. Installed packages currently provide map and local place/camera data. Offline route calculation, global camera completeness, and complete worldwide font coverage are not provided. Route calculation and address search use configurable online services. Spoken output uses the selected language when Android provides voice data; voice availability and offline behavior depend on the device's TextToSpeech engine. Physical validation of route guidance, voice playback, camera alerts, sustained TFT map rendering, and a 30-minute screen-off session remains pending unless a newer test report says otherwise. diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0b68e8a..4de9793 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,7 +15,7 @@ android { applicationId = "dev.navframe.app" minSdk = 26 targetSdk = 35 - versionName = "0.13.7" + versionName = "0.14.6" versionCode = 23 } if (hasReleaseSigning) { diff --git a/docs/ANDROID_RELEASES.md b/docs/ANDROID_RELEASES.md index ece64df..09e4686 100644 --- a/docs/ANDROID_RELEASES.md +++ b/docs/ANDROID_RELEASES.md @@ -19,6 +19,15 @@ The major component only changes on the owner's explicit request. For that excep The policy uses `pull_request_target` with read-only permissions and executes only the base branch's trusted script. It reads PR version declarations with `git show` without building or executing PR code, and never uses production secrets. The existing Android checks continue using the ordinary `pull_request` event. Enable **Branch and version policy** as a required status check in branch protection/rulesets for both destinations to prevent merging a failed policy check. Install this policy on both branches before relying on it for development PRs. If another PR changes the destination version, update the branch/version and rerun the check before merging. +Do not compute the bump by hand. From the PR's source branch, fetch the destination and let the policy script write the required versionName, versionCode and README version, then commit the result: + +```sh +git fetch origin main development +python3 scripts/check_version_policy.py --write --base-ref origin/DESTINATION --base-branch DESTINATION --head-branch SOURCE +``` + +For a promotion, that is `--base-ref origin/main --base-branch main --head-branch development`, committed on `development` before the promotion PR is merged. A failed check prints the same command with the values filled in. Rerun it whenever the destination moves (for example after another hotfix lands on `main`). + CI validates the committed bump rather than pushing version commits with privileged tokens. This keeps the exact app version reviewable in the PR and works for fork contributions as well. ## Branch outputs diff --git a/scripts/check_version_policy.py b/scripts/check_version_policy.py index 61f6e2a..076c63a 100644 --- a/scripts/check_version_policy.py +++ b/scripts/check_version_policy.py @@ -1,22 +1,34 @@ #!/usr/bin/env python3 -"""Validate PR routing and committed Android versions without executing PR code.""" +"""Validate PR routing and committed Android versions without executing PR code. + +With --write, apply the required versionName, versionCode and README version +to the local working tree instead, so a contributor never computes them by hand. +""" import argparse import re import subprocess +from pathlib import Path + +GRADLE = 'app/build.gradle.kts' +README = 'README.md' +NAME_RE = re.compile(r'^(\s*versionName\s*=\s*)"(\d+)\.(\d+)\.(\d+)"(\s*)$', re.M) +CODE_RE = re.compile(r'^(\s*versionCode\s*=\s*)(\d+)(\s*)$', re.M) +README_RE = re.compile(r'(The current checkout is version )\d+\.\d+\.\d+\.') + + +def parse_version(content): + names = NAME_RE.findall(content) + codes = CODE_RE.findall(content) + if len(names) != 1 or len(codes) != 1: + raise ValueError('Expected one literal x.y.z versionName and one versionCode') + return tuple(map(int, names[0][1:4])), int(codes[0][1]) def version_at(ref): - content = subprocess.check_output( - ['git', 'show', f'{ref}:app/build.gradle.kts'], text=True - ) - names = re.findall(r'^\s*versionName\s*=\s*"(\d+)\.(\d+)\.(\d+)"\s*$', content, re.M) - codes = re.findall(r'^\s*versionCode\s*=\s*(\d+)\s*$', content, re.M) - if len(names) != 1 or len(codes) != 1: - raise ValueError('Expected one literal x.y.z versionName and one versionCode') - return tuple(map(int, names[0])), int(codes[0]) + return parse_version(subprocess.check_output(['git', 'show', f'{ref}:{GRADLE}'], text=True)) -def validate(base_branch, head_branch, old, new, old_code, new_code, major_approved=False): +def expected_version(base_branch, head_branch, old, major_approved=False): if base_branch == 'main' and head_branch == 'development': expected = (old[0], old[1] + 1, old[2]) elif base_branch == 'main' and head_branch.startswith('hotfix/'): @@ -27,25 +39,65 @@ def validate(base_branch, head_branch, old, new, old_code, new_code, major_appro raise ValueError('PRs must be feat/* or fix/* -> development, hotfix/* -> main, or development -> main') if major_approved: expected = (old[0] + 1, old[1], old[2]) + return expected + + +def fmt(version): + return '.'.join(map(str, version)) + + +def validate(base_branch, head_branch, old, new, old_code, new_code, major_approved=False): + expected = expected_version(base_branch, head_branch, old, major_approved) if new != expected: - raise ValueError(f'Expected version {".".join(map(str, expected))}, found {".".join(map(str, new))}') + raise ValueError( + f'Expected version {fmt(expected)}, found {fmt(new)}. Fix it with: ' + f'python3 scripts/check_version_policy.py --write --base-ref origin/{base_branch} ' + f'--base-branch {base_branch} --head-branch {head_branch}' + ) if new_code <= old_code or not 1 <= new_code <= 2_100_000_000: - raise ValueError('Committed versionCode must increase and remain within Android limits') + raise ValueError(f'Committed versionCode must increase above {old_code} and remain within Android limits') + + +def apply_version(gradle, readme, version, code): + """Return gradle and README text carrying the given versionName and versionCode.""" + gradle = NAME_RE.sub(lambda m: f'{m[1]}"{fmt(version)}"{m[5]}', gradle) + gradle = CODE_RE.sub(lambda m: f'{m[1]}{code}{m[3]}', gradle) + return gradle, README_RE.sub(lambda m: f'{m[1]}{fmt(version)}.', readme) + + +def write(args): + old, old_code = version_at(args.base_ref) + gradle_path, readme_path = Path(GRADLE), Path(README) + gradle, readme = gradle_path.read_text(), readme_path.read_text() + _, head_code = parse_version(gradle) + version = expected_version(args.base_branch, args.head_branch, old, args.major_approved) + code = head_code if head_code > old_code else old_code + 1 + gradle, readme = apply_version(gradle, readme, version, code) + gradle_path.write_text(gradle) + readme_path.write_text(readme) + print(f'Wrote versionName {fmt(version)} and versionCode {code} ({args.base_branch} has {fmt(old)}, {old_code})') def main(): - parser = argparse.ArgumentParser(description=__doc__) - for name in ('base-ref', 'head-ref', 'base-branch', 'head-branch'): + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + for name in ('base-ref', 'base-branch', 'head-branch'): parser.add_argument(f'--{name}', required=True) + parser.add_argument('--head-ref', help='required unless --write') parser.add_argument('--major-approved', action='store_true') + parser.add_argument('--write', action='store_true', help='update the working tree instead of validating') args = parser.parse_args() - old, old_code = version_at(args.base_ref) - new, new_code = version_at(args.head_ref) try: + if args.write: + write(args) + return + if not args.head_ref: + parser.error('--head-ref is required unless --write is given') + old, old_code = version_at(args.base_ref) + new, new_code = version_at(args.head_ref) validate(args.base_branch, args.head_branch, old, new, old_code, new_code, args.major_approved) except ValueError as error: raise SystemExit(str(error)) from error - print(f'Version policy passed: {old} -> {new}, versionCode {old_code} -> {new_code}') + print(f'Version policy passed: {fmt(old)} -> {fmt(new)}, versionCode {old_code} -> {new_code}') if __name__ == '__main__': diff --git a/scripts/tests/test_version_policy.py b/scripts/tests/test_version_policy.py index 34191a2..b951105 100644 --- a/scripts/tests/test_version_policy.py +++ b/scripts/tests/test_version_policy.py @@ -1,5 +1,5 @@ import unittest -from scripts.check_version_policy import validate +from scripts.check_version_policy import apply_version, parse_version, validate class VersionPolicyTest(unittest.TestCase): @@ -30,6 +30,19 @@ class VersionPolicyTest(unittest.TestCase): with self.assertRaises(ValueError): validate('main', 'feat/major', (0, 13, 4), (1, 13, 4), 20, 21, True) + def test_promotion_keeps_destination_patch(self): + validate('main', 'development', (0, 13, 6), (0, 14, 6), 22, 24) + with self.assertRaises(ValueError): + validate('main', 'development', (0, 13, 6), (0, 13, 7), 22, 23) + + def test_apply_version_rewrites_gradle_and_readme(self): + gradle = ' defaultConfig {\n versionName = "0.13.7"\n versionCode = 23\n }\n' + readme = 'The current checkout is version 0.13.7. The 0.13 series adds voices.\n' + gradle, readme = apply_version(gradle, readme, (0, 14, 6), 24) + self.assertEqual(parse_version(gradle), ((0, 14, 6), 24)) + self.assertIn(' versionCode = 24\n', gradle) + self.assertEqual(readme, 'The current checkout is version 0.14.6. The 0.13 series adds voices.\n') + if __name__ == '__main__': unittest.main()