Kaleido-Desktop/scripts/publish-release.mjs
Elijah Kuntz 7d0803481b Port Kaleido Desktop to macOS
macOS (Apple silicon) now plays, browses and updates like Windows:

- Video: libmpv's render API draws into a CAOpenGLLayer beneath the
  WKWebView, with the miniplayer rectangle, HDR passthrough through
  extended dynamic range (PQ/BT.2020) and display-sleep prevention.
- Window: native traffic lights on the top bar's centre line, hidden
  with the player's controls; the page's caption buttons are Windows-only.
- Interface: macOS shortcut labels (⌘K, ⌘[, ⌃⌘F), Plex identifies the
  player as a Mac, and header values are kept ASCII (Mac computer names
  usually contain a curly apostrophe).
- The window appears without waiting for an animation frame, which
  WKWebView doesn't run in a hidden window.
- Credentials: release builds use the Keychain and are signed with a
  lasting self-signed certificate so access survives updates; debug
  builds keep tokens in a private file to avoid prompts on every rebuild.
- Bundling: scripts/fetch-libmpv.sh makes Homebrew's libmpv and its
  libraries self-contained; scripts/build.sh builds the .app, .dmg and
  signed update archive.

Releases now carry both platforms: publish-release.mjs uploads each
machine's build into one release, and update-manifest.mjs writes the
feed from that release's assets, refusing while a platform is missing.

The updater uses a new signing key (public key in tauri.conf.json), so
existing installs must be reinstalled once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 15:14:40 -07:00

56 lines
2.5 KiB
JavaScript

// Creates (or reuses) a Forgejo release for a tag and uploads this machine's build of it:
// the Windows installer, or the macOS disk image and updater archive, each with its
// updater signature. Run it on each OS after building; both land in the same release.
// Reads FORGEJO_TOKEN from the environment or the ignored .env.
// Usage: node scripts/publish-release.mjs <version> [--prerelease]
import fs from 'node:fs';
import path from 'node:path';
import { api, bundleDir, releaseNotes, token } from './release-common.mjs';
const version = process.argv[2];
const prerelease = process.argv.includes('--prerelease');
if (!version) {
console.error('usage: node scripts/publish-release.mjs <version> [--prerelease]');
process.exit(1);
}
/** This version's release files as built on this OS (scripts/build.ps1 or scripts/build.sh). */
function builtFiles() {
if (process.platform === 'win32') {
const dir = path.join(bundleDir, 'nsis');
return [`Kaleido_${version}_x64-setup.exe`, `Kaleido_${version}_x64-setup.exe.sig`].map((n) => path.join(dir, n));
}
if (process.platform === 'darwin') {
const arch = process.arch === 'arm64' ? 'aarch64' : 'x64';
return [
path.join(bundleDir, 'dmg', `Kaleido_${version}_${arch}.dmg`),
path.join(bundleDir, 'macos', `Kaleido_${version}_${arch}.app.tar.gz`),
path.join(bundleDir, 'macos', `Kaleido_${version}_${arch}.app.tar.gz.sig`),
];
}
throw new Error('Publish releases from Windows or macOS.');
}
token(true);
const files = builtFiles();
for (const file of files) {
if (!fs.existsSync(file)) throw new Error(`Missing ${file}; build this version first.`);
}
const tag = `v${version}`;
let release = await api('GET', `/releases/tags/${tag}`).catch(() => null);
if (!release) {
release = await api('POST', '/releases', { tag_name: tag, name: `Kaleido Desktop ${version}`, body: releaseNotes(version), prerelease, draft: false });
console.log(`Created release ${release.name}`);
} else console.log(`Using existing release ${release.name}`);
for (const file of files) {
const name = path.basename(file);
const existing = release.assets?.find((a) => a.name === name);
if (existing) await api('DELETE', `/releases/${release.id}/assets/${existing.id}`);
const form = new FormData();
form.append('attachment', new Blob([fs.readFileSync(file)]), name);
const asset = await api('POST', `/releases/${release.id}/assets?name=${encodeURIComponent(name)}`, form);
console.log(`Uploaded ${asset.name} (${asset.size} bytes): ${asset.browser_download_url}`);
}
console.log(release.html_url);