1#!/usr/bin/env node
Run by nix run .#deploy before it publishes: refuses a site whose
newest release note is already live, so every deploy carries notes for
the update modal. Usage: release-check.mjs <built release-notes.json>
8const built = JSON.parse(readFileSync(process.argv[2], 'utf8')); 9if (!built.length) { 10 console.error('release-check: RELEASES.md has no notes; add one for this deploy'); 11 process.exit(1); 12} 13let live = []; 14try { 15 const res = await fetch(`${siteUrl}/release-notes.json`, { 16 headers: { 'User-Agent': 'jevstrudel-deploy', 'Cache-Control': 'no-cache' }, 17 }); 18 // Before the first deploy with notes the path is the SPA's 404 or HTML. 19 if (res.ok && (res.headers.get('content-type') ?? '').includes('json')) live = await res.json(); 20} catch (e) { 21 console.error(`release-check: could not read the live notes (${e.message}); deploying`); 22} 23if (live[0]?.version === built[0].version) { 24 console.error( 25 `release-check: ${built[0].version} is already live. Add a new note at the top of RELEASES.md for this deploy.`, 26 ); 27 process.exit(1); 28} 29console.error( 30 `release-check: publishing ${built[0].version} — ${built[0].title} (live: ${live[0]?.version ?? 'none'})`, 31);