diff --git a/scripts/release-gitea.mjs b/scripts/release-gitea.mjs index 16b63aa..54e8bf3 100644 --- a/scripts/release-gitea.mjs +++ b/scripts/release-gitea.mjs @@ -100,15 +100,30 @@ async function main() { for (const [key, { file, sig }] of Object.entries(updater)) { platforms[key] = { signature: sig, url: dlUrl(verTag, path.basename(file)) }; } + + // Merge with the currently-published latest.json so a split release (e.g. macOS + // on one machine, Linux on another) doesn't drop the platform we didn't build + // this run — as long as both build the SAME version. A published older version + // is ignored (a fresh version starts clean; the other platform re-publishes). + let merged = platforms; + try { + const cur = await fetch(dlUrl(UPDATER_TAG, 'latest.json')).then((r) => (r.ok ? r.json() : null)); + if (cur && cur.version === VERSION && cur.platforms) { + const kept = Object.keys(cur.platforms).filter((k) => !platforms[k]); + merged = { ...cur.platforms, ...platforms }; + if (kept.length) console.log('Merged kept platforms from published latest.json:', kept.join(', ')); + } + } catch { /* offline / first ever release */ } + const latest = { version: VERSION, notes: `X-Plane Cockpit ${verTag}`, pub_date: new Date().toISOString(), - platforms, + platforms: merged, }; const latestPath = path.join(ROOT, 'desktop/latest.json'); fs.writeFileSync(latestPath, JSON.stringify(latest, null, 2)); - console.log('latest.json platforms:', Object.keys(platforms).join(', ') || '(none)'); + console.log('latest.json platforms:', Object.keys(merged).join(', ') || '(none)'); // Upload latest.json to the fixed "updater" release (constant endpoint URL). const upd = await ensureRelease(UPDATER_TAG, 'Updater channel', 'Rolling pointer used by the in-app updater.');