123456import { execSync } from "child_process";7import { readFileSync, existsSync, mkdirSync } from "fs";8import { join } from "path";910const ROOT = process.cwd();1112function run(cmd: string, label?: string, env?: Record<string, string>) {13 const display = label ?? cmd;14 console.log(`\n▶ ${display}`);15 execSync(cmd, { stdio: "inherit", cwd: ROOT, env: { ...process.env, ...env } });16}1718function fail(msg: string): never {19 console.error(`\n✗ ${msg}`);20 process.exit(1);21}22232425if (!process.env.AMO_JWT_ISSUER) {26 fail("AMO_JWT_ISSUER not set. Add it to your shell profile and reload.");27}28if (!process.env.AMO_JWT_SECRET) {29 fail("AMO_JWT_SECRET not set. Add it to your shell profile and reload.");30}31323334const manifest = JSON.parse(35 readFileSync(join(ROOT, "manifest.firefox.json"), "utf8")36);37const version = manifest.version;38if (!version) fail("Could not read version from manifest.firefox.json");39console.log(`\n🍑 Peach Firefox — releasing v${version}`);40414243run("npm run ci", "Running CI gate");44454647run("npm run build:firefox", `Building Firefox extension v${version}`);484950515253const sourceZip = `peach-source-${version}.zip`;54run(55 [56 "zip -r",57 sourceZip,58 "src",59 "scripts",60 "public",61 "manifest.json",62 "manifest.firefox.json",63 "package.json",64 "bun.lock",65 "tsconfig.json",66 "vite.config.ts",67 "--exclude 'node_modules/*'",68 "--exclude 'dist-*/*'",69 "--exclude '*.zip'",70 "--exclude '.DS_Store'",71 "--exclude '__MACOSX/*'",72 ].join(" "),73 "Packaging source archive for AMO"74);75767778if (!existsSync(join(ROOT, "artifacts"))) {79 mkdirSync(join(ROOT, "artifacts"));80}81828384run(85 [86 "npx web-ext sign",87 "--source-dir dist-firefox",88 "--artifacts-dir artifacts",89 "--channel=listed",90 ].join(" "),91 "Signing and submitting to AMO",92 93 94 {95 WEB_EXT_API_KEY: process.env.AMO_JWT_ISSUER!,96 WEB_EXT_API_SECRET: process.env.AMO_JWT_SECRET!,97 }98);99100101102run(`trash ${sourceZip}`, "Cleaning up source zip");103104105106console.log(`\n✓ Peach Firefox v${version} submitted to AMO.`);107console.log(" Existing users will receive the update automatically.");108console.log(" Check AMO developer hub for review status.");109console.log("");