Fix Windows build, make data version unique per publish, verify data … #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish reference data | |
| # Regenerates the bundled reference data (airports, frequencies, runways, | |
| # airspace) from OurAirports on a schedule and publishes it to a moving | |
| # `data-latest` GitHub release. The desktop app checks this release on launch | |
| # and downloads a newer bundle for use on the next launch. | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'scripts/build-airspace.mjs' | |
| - 'scripts/build-nasr-data.mjs' | |
| - 'scripts/airport-defaults.json' | |
| - 'scripts/write-scope-airports.mjs' | |
| - 'scripts/sua-overrides.json' | |
| - '.github/workflows/data-update.yml' | |
| schedule: | |
| - cron: '0 8 * * 1' # Mondays 08:00 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish-data: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - run: npm ci | |
| - name: Download OurAirports CSVs | |
| run: | | |
| mkdir -p scripts/nasr | |
| dl() { | |
| curl -fsSL -o "scripts/nasr/$1" "https://davidmegginson.github.io/ourairports-data/$1" \ | |
| || curl -fsSL -o "scripts/nasr/$1" "https://ourairports.com/data/$1" | |
| } | |
| dl airports.csv | |
| dl airport-frequencies.csv | |
| dl runways.csv | |
| - name: Refresh airspace dataset (best effort) | |
| run: npm install --no-save @squawk/airspace-data@latest || true | |
| - name: Regenerate data | |
| run: npm run build:reference-data | |
| - name: Publish to data-latest release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release view data-latest >/dev/null 2>&1 || \ | |
| gh release create data-latest \ | |
| --title "FreqScope reference data (latest)" \ | |
| --notes "Auto-published reference data. The desktop app downloads this on launch." \ | |
| --prerelease --target "$GITHUB_SHA" | |
| gh release upload data-latest \ | |
| src/data/airports.json \ | |
| src/data/frequencies.json \ | |
| src/data/runways.json \ | |
| src/data/airspace.json \ | |
| src/data/artcc.json \ | |
| src/data/sua.json \ | |
| src/data/data-meta.json \ | |
| src/data/scope-airports.json \ | |
| src/data/data-manifest.json \ | |
| --clobber | |
| - name: Verify the feed is reachable | |
| run: | | |
| URL="https://github.com/${GITHUB_REPOSITORY}/releases/download/data-latest/data-manifest.json" | |
| echo "Checking $URL" | |
| curl -fsSL "$URL" | tee /tmp/manifest.json | |
| node -e "const m=require('/tmp/manifest.json'); if(!m.version||!Array.isArray(m.files)||!m.files.length){console.error('feed manifest invalid');process.exit(1)} console.log('feed OK — version',m.version)" |