also looking at this
fix(release): derive the app version instead of copying it
#53
5 files
+73
-2
| @@ -0,0 +1,44 @@ | ||
| 1 | #!/usr/bin/env bun | |
| 2 | import process from 'node:process' | |
| 3 | import { infoPlist } from '../../app/Uplink/service' | |
| 4 | import pkg from '../../package.json' | |
| 5 | import release from '../../resources/data/release.json' | |
| 6 | ||
| 7 | /** | |
| 8 | * The version lives in package.json. Everything else derives it, and this says | |
| 9 | * so out loud in CI. | |
| 10 | * | |
| 11 | * It used to live in four places. Two of them drifted: the homepage advertised | |
| 12 | * 0.1.0 while the tree built 0.1.1, and the bundle `uplink:install` writes | |
| 13 | * reported 0.1.0 whatever it was built from. Nothing failed, because nothing | |
| 14 | * compared them (#29). | |
| 15 | * | |
| 16 | * `release.json` is written and committed by `buddy uplink:release`, so if this | |
| 17 | * fails the usual cause is a version bumped without a release. The homepage is | |
| 18 | * advertising the previous build until one happens, which is worth knowing. | |
| 19 | */ | |
| 20 | ||
| 21 | const problems: string[] = [] | |
| 22 | ||
| 23 | if (release.version !== pkg.version) { | |
| 24 | problems.push( | |
| 25 | `resources/data/release.json says ${release.version}, package.json says ${pkg.version}.`, | |
| 26 | ' The homepage download button reads release.json, so it is advertising a different build.', | |
| 27 | ' `buddy uplink:release` writes and commits that file: run a release, or put the version back.', | |
| 28 | ) | |
| 29 | } | |
| 30 | ||
| 31 | if (!infoPlist().includes(`<string>${pkg.version}</string>`)) { | |
| 32 | problems.push( | |
| 33 | `The Info.plist in app/Uplink/service.ts does not carry ${pkg.version}.`, | |
| 34 | ' It should interpolate pkg.version rather than naming a version of its own.', | |
| 35 | ) | |
| 36 | } | |
| 37 | ||
| 38 | if (problems.length > 0) { | |
| 39 | console.error('The app version is not consistent:\n') | |
| 40 | console.error(problems.join('\n')) | |
| 41 | process.exit(1) | |
| 42 | } | |
| 43 | ||
| 44 | console.log(`Version ${pkg.version} agrees across package.json, release.json and the Info.plist.`) | |