import { readFile, writeFile } from "node:fs/promises"; import process from "node:process"; const repository = "https://githop.xyz/GnosysLabs/Synapsis-Desktop"; const bundleDirectory = new URL("../src-tauri/target/release/bundle/macos/", import.meta.url); const config = JSON.parse( await readFile(new URL("../src-tauri/tauri.conf.json", import.meta.url), "utf8"), ); const version = config.version; const tag = process.env.SYNAPSIS_RELEASE_TAG || `v${version}`; const notes = process.env.SYNAPSIS_RELEASE_NOTES || `Synapsis ${version}`; const archiveName = "Synapsis.app.tar.gz"; const signature = ( await readFile(new URL(`${archiveName}.sig`, bundleDirectory), "utf8") ).trim(); const architecture = process.arch === "arm64" ? "aarch64" : "x86_64"; const manifest = { version, notes, pub_date: new Date().toISOString(), platforms: { [`darwin-${architecture}`]: { signature, url: `${repository}/releases/download/${encodeURIComponent(tag)}/${archiveName}`, }, }, }; const destination = new URL("latest.json", bundleDirectory); await writeFile(destination, `${JSON.stringify(manifest, null, 2)}\n`); console.log(`Created updater manifest for Synapsis ${version}.`);