Compare commits

...
Author SHA1 Message Date
dasemu 463c74efe2 Prepare worldwide offline package campaign 2026-09-30 18:21:53 +02:00
7 changed files with 807 additions and 4 deletions

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
name: Android build and checks
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
+7 -2
View File
@@ -1,7 +1,7 @@
name: Build worldwide offline regions
on:
push:
tags: ['offline-bootstrap-andorra', 'offline-bootstrap-andorra-*']
tags: ['offline-bootstrap-andorra', 'offline-bootstrap-andorra-*', 'offline-global-2026-09-batch-*']
workflow_dispatch:
inputs:
regions:
@@ -23,9 +23,14 @@ jobs:
- uses: actions/checkout@v4
- id: matrix
env:
CAMPAIGN_TAG: ${{ github.ref_name }}
REGION_IDS: ${{ github.event_name == 'push' && 'andorra' || inputs.regions }}
run: |
value=$(python3 tools/offline/global-regions.py matrix "$REGION_IDS")
if [[ "$CAMPAIGN_TAG" == offline-global-2026-09-batch-* && "${{ github.event_name }}" == push ]]; then
value=$(python3 tools/offline/campaign.py matrix "$CAMPAIGN_TAG")
else
value=$(python3 tools/offline/global-regions.py matrix "$REGION_IDS")
fi
echo "value=$value" >> "$GITHUB_OUTPUT"
build:
needs: plan
@@ -0,0 +1,19 @@
name: Refresh offline package catalog
on:
workflow_dispatch:
permissions:
contents: write
jobs:
catalog:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: offline-catalog-publication
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: Rebuild index from all published regional releases
env:
GH_TOKEN: ${{ github.token }}
run: python3 tools/offline/publish-catalog.py
+10 -2
View File
@@ -6,6 +6,14 @@ The app installs individual `.navframe` packages containing a PMTiles map, a SQL
In `Dasemu/NavFrame`, open **Actions → Build worldwide offline regions → Run workflow**. Enter Geofabrik IDs such as `andorra,act,cantabria,us/california`. First run with **publish = false** to inspect artifacts; run with **publish = true** to publish packages. Each run builds at most 32 independent regions, with two concurrent builders and a 330-minute timeout per builder. No planet download or full-world local build is performed.
The frozen `tools/offline/campaign-global-2026-09.json` contains the global leaf-region campaign, split into 17 tag-triggered batches. It excludes parent extracts to avoid overlapping coverage and excludes packages already present when the manifest was created. Push the batch tags to queue all remaining eligible regions:
```sh
for n in $(seq -w 1 17); do git push origin "offline-global-2026-09-batch-0$n"; done
```
Each batch publishes successful packages independently; oversized or otherwise unsupported extracts fail as individual matrix jobs. GitHub's catalog concurrency allows one running and one pending refresh, so after all batches complete, run **Actions → Refresh offline package catalog → Run workflow** once to ensure the index includes every successful package.
One-time bootstrap with SSH push access (no local GitHub CLI/token required): after pushing the project to the default branch, create and push the exact tag below. Only this tag and `offline-bootstrap-andorra-*` retry tags trigger an automatic **Andorra** build with publication enabled; other tag or branch pushes do not trigger the offline builder. The catalog becomes available after that workflow succeeds. For a retry after fixing a failed run, push a new tag such as `offline-bootstrap-andorra-v2`; preserve existing tags.
```sh
@@ -35,13 +43,13 @@ python3 tools/offline/global-regions.py build --region andorra --version 2026093
Every package publishes a release `offline-gf-REGION-RUNID.ATTEMPT` with the package and `regional-catalog.json`. The workflow creates a draft, uploads assets, then publishes it; it never replaces package assets. Published region releases should be treated as immutable. Package manifests retain schema version 1 and stable IDs `gf-REGION` (slashes in upstream IDs become hyphens, e.g. `us/california` → `gf-us-california`).
The serialized catalog job reads **all** published region releases, merges their fragments and selects the latest publication per region. The merged index uses compact JSON and is checked against a 32 MiB / 4,096-entry Android discovery budget before publication.
The catalog job reads **all** published region releases, merges their fragments and selects the latest publication per region. Concurrent campaign runs may coalesce pending catalog refreshes; use the manual refresh workflow after a large campaign completes. The merged index uses compact JSON and is checked against a 32 MiB / 4,096-entry Android discovery budget before publication.
The mutable discovery index is:
`https://github.com/Dasemu/NavFrame/releases/download/offline-catalog/regional-catalog.json`
This index release must remain mutable so its asset can be updated; do not enable repository-wide release immutability without moving the index to another host. The individual package URLs remain versioned. Historical package releases remain available. Catalog rebuilding is safe across concurrent region batches because the index job is serialized. A failed region does not prevent catalog rebuilding for successful releases.
This index release must remain mutable so its asset can be updated; do not enable repository-wide release immutability without moving the index to another host. The individual package URLs remain versioned. Historical package releases remain available. Catalog rebuilding is serialized. A failed region does not prevent catalog rebuilding for successful releases.
Catalog format:
+652
View File
@@ -0,0 +1,652 @@
{
"schemaVersion": 1,
"campaign": "global-2026-09",
"sourceSha256": "f4dd095bb0a3619ae643bcb05a0bdcbc5143660660b08a77589a7bbb6b5d6548",
"catalogSha256": "0fa691b64842cb84ee303a70d9b550bb081e02a97d31ebda4d3168bf0bc2ad6c",
"excludedParents": [
"africa",
"asia",
"australia",
"australia-oceania",
"baden-wuerttemberg",
"bayern",
"brazil",
"british-columbia",
"canada",
"central-america",
"china",
"czech-republic",
"england",
"europe",
"france",
"germany",
"greater-london",
"india",
"indonesia",
"italy",
"japan",
"netherlands",
"nordrhein-westfalen",
"north-america",
"norway",
"nunavut",
"poland",
"russia",
"south-america",
"spain",
"united-kingdom",
"us/california"
],
"excludedPublished": [
"andorra"
],
"batches": [
{
"tag": "offline-global-2026-09-batch-001",
"regions": [
"act",
"afghanistan",
"albania",
"alberta",
"algeria",
"alps",
"alsace",
"american-oceania",
"andalucia",
"angola",
"anhui",
"antarctica",
"aquitaine",
"aragon",
"argentina",
"armenia",
"arnsberg-regbez",
"ashmore-cartier",
"asturias",
"austria",
"auvergne",
"azerbaijan",
"azores",
"bahamas",
"bangladesh",
"basse-normandie",
"bedfordshire",
"beijing",
"belarus",
"belgium",
"belize",
"benin"
]
},
{
"tag": "offline-global-2026-09-batch-002",
"regions": [
"berkshire",
"berlin",
"bermuda",
"bhutan",
"bolivia",
"bosnia-herzegovina",
"botswana",
"bourgogne",
"brandenburg",
"bremen",
"bretagne",
"bristol",
"britain-and-ireland",
"buckinghamshire",
"bulgaria",
"burkina-faso",
"burundi",
"cambodia",
"cambridgeshire",
"cameroon",
"canary-islands",
"cantabria",
"cape-verde",
"castilla-la-mancha",
"castilla-y-leon",
"cataluna",
"central-african-republic",
"central-fed-district",
"central-zone",
"centre",
"centro",
"centro-oeste"
]
},
{
"tag": "offline-global-2026-09-batch-003",
"regions": [
"ceuta",
"chad",
"champagne-ardenne",
"cheshire",
"chile",
"chongqing",
"christmas-island",
"chubu",
"chugoku",
"cocos-islands",
"colombia",
"comores",
"congo-brazzaville",
"congo-democratic-republic",
"cook-islands",
"coral-sea-islands",
"cornwall",
"corse",
"costa-rica",
"crimean-fed-district",
"croatia",
"cuba",
"cumbria",
"cyprus",
"dach",
"denmark",
"derbyshire",
"detmold-regbez",
"devon",
"djibouti",
"dolnoslaskie",
"dorset"
]
},
{
"tag": "offline-global-2026-09-batch-004",
"regions": [
"drenthe",
"duesseldorf-regbez",
"durham",
"east-sussex",
"east-timor",
"east-yorkshire-with-hull",
"eastern-zone",
"ecuador",
"egypt",
"el-salvador",
"enfield",
"equatorial-guinea",
"eritrea",
"essex",
"estonia",
"ethiopia",
"extremadura",
"falklands",
"far-eastern-fed-district",
"faroe-islands",
"fiji",
"finland",
"flevoland",
"franche-comte",
"freiburg-regbez",
"friesland",
"fujian",
"gabon",
"galicia",
"gansu",
"gcc-states",
"gelderland"
]
},
{
"tag": "offline-global-2026-09-batch-005",
"regions": [
"georgia",
"ghana",
"gloucestershire",
"great-britain",
"greater-manchester",
"greece",
"greenland",
"groningen",
"guadeloupe",
"guangdong",
"guangxi",
"guatemala",
"guernsey-jersey",
"guinea",
"guinea-bissau",
"guizhou",
"guyana",
"guyane",
"hainan",
"haiti-and-domrep",
"hamburg",
"hampshire",
"haute-normandie",
"heard-mcdonald",
"hebei",
"heilongjiang",
"henan",
"herefordshire",
"hertfordshire",
"hessen",
"hokkaido",
"honduras"
]
},
{
"tag": "offline-global-2026-09-batch-006",
"regions": [
"hong-kong",
"hubei",
"hunan",
"hungary",
"iceland",
"ile-de-clipperton",
"ile-de-france",
"inner-mongolia",
"interior-admreg",
"iran",
"iraq",
"ireland-and-northern-ireland",
"island-admreg",
"islas-baleares",
"isle-of-man",
"isle-of-wight",
"isole",
"israel-and-palestine",
"ivory-coast",
"jamaica",
"java",
"jiangsu",
"jiangxi",
"jihocesky",
"jihomoravsky",
"jilin",
"jordan",
"kalimantan",
"kaliningrad",
"kansai",
"kanto",
"karlovarsky"
]
},
{
"tag": "offline-global-2026-09-batch-007",
"regions": [
"karlsruhe-regbez",
"kazakhstan",
"kent",
"kenya",
"kiribati",
"kitikmeot",
"kivalliq",
"koeln-regbez",
"kootenay-admreg",
"kosovo",
"kralovehradecky",
"kujawsko-pomorskie",
"kyrgyzstan",
"kyushu",
"la-rioja",
"lancashire",
"languedoc-roussillon",
"laos",
"latvia",
"lebanon",
"leicestershire",
"lesotho",
"liaoning",
"liberecky",
"liberia",
"libya",
"liechtenstein",
"limburg",
"limousin",
"lincolnshire",
"lithuania",
"lodzkie"
]
},
{
"tag": "offline-global-2026-09-batch-008",
"regions": [
"lorraine",
"lubelskie",
"lubuskie",
"luxembourg",
"macau",
"macedonia",
"madagascar",
"madrid",
"malawi",
"malaysia-singapore-brunei",
"maldives",
"mali",
"malopolskie",
"malta",
"maluku",
"manitoba",
"marshall-islands",
"martinique",
"mauritania",
"mauritius",
"mayotte",
"mazowieckie",
"mecklenburg-vorpommern",
"melilla",
"merseyside",
"mexico",
"micronesia",
"midi-pyrenees",
"mittelfranken",
"moldova",
"monaco",
"mongolia"
]
},
{
"tag": "offline-global-2026-09-batch-009",
"regions": [
"montenegro",
"moravskoslezky",
"morocco",
"mozambique",
"muenster-regbez",
"murcia",
"myanmar",
"namibia",
"nauru",
"navarra",
"nepal",
"new-brunswick",
"new-caledonia",
"new-south-wales",
"new-zealand",
"newfoundland-and-labrador",
"nicaragua",
"niederbayern",
"niedersachsen",
"niger",
"nigeria",
"ningxia",
"niue",
"noord-brabant",
"noord-holland",
"norcal",
"nord-est",
"nord-norge",
"nord-ovest",
"nord-pas-de-calais",
"nordeste",
"norfolk"
]
},
{
"tag": "offline-global-2026-09-batch-010",
"regions": [
"norfolk-island",
"norte",
"north-admreg",
"north-caucasus-fed-district",
"north-eastern-zone",
"north-korea",
"north-yorkshire",
"northamptonshire",
"northern-territory",
"northern-zone",
"northumberland",
"northwest-territories",
"northwestern-fed-district",
"nottinghamshire",
"nova-scotia",
"nusa-tenggara",
"oberbayern",
"oberfranken",
"oberpfalz",
"okanagan-admreg",
"olomoucky",
"ontario",
"opolskie",
"ostlandet",
"overijssel",
"oxfordshire",
"pais-vasco",
"pakistan",
"palau",
"panama",
"papua",
"papua-new-guinea"
]
},
{
"tag": "offline-global-2026-09-batch-011",
"regions": [
"paraguay",
"pardubicky",
"pays-de-la-loire",
"peru",
"philippines",
"picardie",
"pitcairn-islands",
"plzensky",
"podkarpackie",
"podlaskie",
"poitou-charentes",
"polynesie-francaise",
"pomorskie",
"portugal",
"praha",
"prince-edward-island",
"provence-alpes-cote-d-azur",
"qikiqtaaluk",
"qinghai",
"quebec",
"queensland",
"reunion",
"rheinland-pfalz",
"rhone-alpes",
"romania",
"rutland",
"rwanda",
"saarland",
"sachsen",
"sachsen-anhalt",
"saint-helena-ascension-and-tristan-da-cunha",
"samoa"
]
},
{
"tag": "offline-global-2026-09-batch-012",
"regions": [
"sao-tome-and-principe",
"saskatchewan",
"schleswig-holstein",
"schwaben",
"scotland",
"sea",
"senegal-and-gambia",
"serbia",
"seychelles",
"shaanxi",
"shandong",
"shanghai",
"shanxi",
"shikoku",
"shropshire",
"siberian-fed-district",
"sichuan",
"sierra-leone",
"slaskie",
"slovakia",
"slovenia",
"socal",
"solomon-islands",
"somalia",
"somerset",
"sorlandet",
"south-africa",
"south-africa-and-lesotho",
"south-australia",
"south-fed-district",
"south-korea",
"south-sudan"
]
},
{
"tag": "offline-global-2026-09-batch-013",
"regions": [
"south-yorkshire",
"southcoast-admreg",
"southern-zone",
"sri-lanka",
"staffordshire",
"stredocesky",
"stuttgart-regbez",
"sud",
"sudan",
"sudeste",
"suffolk",
"sul",
"sulawesi",
"sumatra",
"suriname",
"surrey",
"svalbard-janmayen",
"swaziland",
"sweden",
"swietokrzyskie",
"switzerland",
"syria",
"taiwan",
"tajikistan",
"tanzania",
"tasmania",
"thailand",
"thueringen",
"tianjin",
"tibet",
"togo",
"tohoku"
]
},
{
"tag": "offline-global-2026-09-batch-014",
"regions": [
"tokelau",
"tonga",
"trondelag",
"tuebingen-regbez",
"tunisia",
"turkey",
"turkmenistan",
"tuvalu",
"tyne-and-wear",
"uganda",
"ukraine",
"unterfranken",
"ural-fed-district",
"uruguay",
"us",
"us-midwest",
"us-northeast",
"us-pacific",
"us-south",
"us-west",
"us/alabama",
"us/alaska",
"us/arizona",
"us/arkansas",
"us/colorado",
"us/connecticut",
"us/delaware",
"us/district-of-columbia",
"us/florida",
"us/georgia",
"us/hawaii",
"us/idaho"
]
},
{
"tag": "offline-global-2026-09-batch-015",
"regions": [
"us/illinois",
"us/indiana",
"us/iowa",
"us/kansas",
"us/kentucky",
"us/louisiana",
"us/maine",
"us/maryland",
"us/massachusetts",
"us/michigan",
"us/minnesota",
"us/mississippi",
"us/missouri",
"us/montana",
"us/nebraska",
"us/nevada",
"us/new-hampshire",
"us/new-jersey",
"us/new-mexico",
"us/new-york",
"us/north-carolina",
"us/north-dakota",
"us/ohio",
"us/oklahoma",
"us/oregon",
"us/pennsylvania",
"us/puerto-rico",
"us/rhode-island",
"us/south-carolina",
"us/south-dakota",
"us/tennessee",
"us/texas"
]
},
{
"tag": "offline-global-2026-09-batch-016",
"regions": [
"us/us-virgin-islands",
"us/utah",
"us/vermont",
"us/virginia",
"us/washington",
"us/west-virginia",
"us/wisconsin",
"us/wyoming",
"ustecky",
"utrecht",
"uzbekistan",
"valencia",
"vanuatu",
"venezuela",
"vestlandet",
"victoria",
"vietnam",
"volga-fed-district",
"vysocina",
"wales",
"wallis-et-futuna",
"warminsko-mazurskie",
"warwickshire",
"west-midlands",
"west-sussex",
"west-yorkshire",
"western-australia",
"western-zone",
"wielkopolskie",
"wiltshire",
"worcestershire",
"xinjiang"
]
},
{
"tag": "offline-global-2026-09-batch-017",
"regions": [
"yemen",
"yukon",
"yunnan",
"zachodniopomorskie",
"zambia",
"zeeland",
"zhejiang",
"zimbabwe",
"zlinsky",
"zuid-holland"
]
}
]
}
+78
View File
@@ -0,0 +1,78 @@
#!/usr/bin/env python3
"""Freeze global leaf batches and resolve campaign tags without network discovery."""
import argparse
import hashlib
import json
from pathlib import Path
import re
PREFIX = 'offline-global-2026-09-batch-'
DEFAULT = Path(__file__).with_name('campaign-global-2026-09.json')
def create(sources, catalog, source_bytes, catalog_bytes):
rows = sources['regions']
ids = [row['id'] for row in rows]
if len(ids) != len(set(ids)):
raise ValueError('Duplicate source IDs')
parents = {row['parent'] for row in rows if row.get('parent')}
published = {entry.get('region') for entry in catalog['regions'] if entry.get('region')}
published_packages = {entry['manifest']['id'] for entry in catalog['regions']}
excluded = sorted(identifier for identifier in ids if identifier in published or 'gf-' + identifier.replace('/', '-') in published_packages)
selected = sorted(set(ids) - parents - set(excluded))
slugs = [identifier.replace('/', '-') for identifier in selected]
if len(slugs) != len(set(slugs)):
raise ValueError('Package slug collision')
return {'schemaVersion': 1, 'campaign': 'global-2026-09',
'sourceSha256': hashlib.sha256(source_bytes).hexdigest(),
'catalogSha256': hashlib.sha256(catalog_bytes).hexdigest(),
'excludedParents': sorted(set(ids) & parents), 'excludedPublished': excluded,
'batches': [{'tag': PREFIX + f'{i // 32 + 1:03d}', 'regions': selected[i:i + 32]}
for i in range(0, len(selected), 32)]}
def select(campaign, tag):
if campaign.get('schemaVersion') != 1 or campaign.get('campaign') != 'global-2026-09':
raise ValueError('Unsupported campaign')
all_ids, all_tags = [], []
selected = None
for batch in campaign['batches']:
ids = batch['regions']
if not 1 <= len(ids) <= 32 or any(not re.fullmatch(r'[a-z0-9]+(?:[-/][a-z0-9]+)*', item) for item in ids):
raise ValueError('Invalid campaign batch')
if not re.fullmatch(re.escape(PREFIX) + r'\d{3}', batch['tag']):
raise ValueError('Invalid campaign tag')
all_ids.extend(ids)
all_tags.append(batch['tag'])
if batch['tag'] == tag:
selected = ids
if len(all_ids) != len(set(all_ids)) or len(all_tags) != len(set(all_tags)):
raise ValueError('Duplicate campaign region or tag')
if set(all_ids) & (set(campaign['excludedParents']) | set(campaign['excludedPublished'])):
raise ValueError('Campaign includes excluded region')
if selected is None:
raise ValueError('Tag is not present in frozen campaign')
return {'region': selected}
def main():
parser = argparse.ArgumentParser(description=__doc__)
sub = parser.add_subparsers(dest='command', required=True)
build = sub.add_parser('create')
build.add_argument('--sources', type=Path, default=Path(__file__).with_name('worldwide-sources.json'))
build.add_argument('--catalog', type=Path, required=True)
build.add_argument('--output', type=Path, default=DEFAULT)
matrix = sub.add_parser('matrix')
matrix.add_argument('tag')
matrix.add_argument('--campaign', type=Path, default=DEFAULT)
args = parser.parse_args()
if args.command == 'create':
source_bytes, catalog_bytes = args.sources.read_bytes(), args.catalog.read_bytes()
result = create(json.loads(source_bytes), json.loads(catalog_bytes), source_bytes, catalog_bytes)
args.output.write_text(json.dumps(result, indent=2) + '\n')
else:
print(json.dumps(select(json.loads(args.campaign.read_text()), args.tag)))
if __name__ == '__main__':
main()
+40
View File
@@ -0,0 +1,40 @@
import importlib.util
import json
from pathlib import Path
import unittest
spec = importlib.util.spec_from_file_location('campaign', Path(__file__).with_name('campaign.py'))
campaign = importlib.util.module_from_spec(spec)
spec.loader.exec_module(campaign)
class CampaignTest(unittest.TestCase):
def test_reproducible_leaf_selection_and_published_exclusion(self):
rows = [{'id': 'parent', 'parent': None}, {'id': 'child', 'parent': 'parent'},
{'id': 'published', 'parent': None}] + [{'id': f'r{i:03}', 'parent': None} for i in range(33)]
catalog = {'regions': [{'manifest': {'id': 'gf-published'}}]}
result = campaign.create({'regions': rows}, catalog, b'sources', b'catalog')
self.assertEqual(result, campaign.create({'regions': list(reversed(rows))}, catalog, b'sources', b'catalog'))
self.assertEqual(result['excludedParents'], ['parent'])
self.assertEqual(result['excludedPublished'], ['published'])
self.assertEqual([len(batch['regions']) for batch in result['batches']], [32, 2])
self.assertEqual(campaign.select(result, campaign.PREFIX + '002')['region'], ['r031', 'r032'])
with self.assertRaises(ValueError):
campaign.select(result, campaign.PREFIX + '003')
result['batches'][1]['regions'].append('child')
with self.assertRaises(ValueError):
campaign.select(result, campaign.PREFIX + '001')
def test_frozen_manifest_is_bounded_disjoint_and_matches_sources(self):
root = Path(__file__).parent
frozen = json.loads((root / 'campaign-global-2026-09.json').read_text())
sources = json.loads((root / 'worldwide-sources.json').read_text())
parents = {row['parent'] for row in sources['regions']}
expected = {row['id'] for row in sources['regions']} - parents - set(frozen['excludedPublished'])
actual = []
for batch in frozen['batches']:
actual.extend(campaign.select(frozen, batch['tag'])['region'])
self.assertEqual(set(actual), expected)
self.assertEqual(len(actual), len(expected))
import hashlib
self.assertEqual(frozen['sourceSha256'], hashlib.sha256((root / 'worldwide-sources.json').read_bytes()).hexdigest())