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}`);48495051525354if (!existsSync(join(ROOT, "artifacts"))) {55 mkdirSync(join(ROOT, "artifacts"));56}57const sourceZip = join(ROOT, "artifacts", `peach-source-${version}.zip`);58run(59 [60 "zip -r",61 sourceZip,62 "src",63 "scripts",64 "public",65 66 67 68 "crypto-core",69 "manifest.json",70 "manifest.firefox.json",71 "package.json",72 "bun.lock",73 "tsconfig.json",74 "vite.config.ts",75 "--exclude 'node_modules/*'",76 "--exclude 'dist-*/*'",77 "--exclude 'crypto-core/target/*'",78 "--exclude 'crypto-core/generated/*'",79 "--exclude '*.zip'",80 "--exclude '.DS_Store'",81 "--exclude '__MACOSX/*'",82 ].join(" "),83 "Packaging source archive for AMO"84);85868788if (!existsSync(join(ROOT, "artifacts"))) {89 mkdirSync(join(ROOT, "artifacts"));90}91929394run(95 [96 "npx web-ext sign",97 "--source-dir dist-firefox",98 "--artifacts-dir artifacts",99 "--channel=listed",100 "--upload-source-code",101 sourceZip,102 ].join(" "),103 "Signing and submitting to AMO",104 105 106 {107 WEB_EXT_API_KEY: process.env.AMO_JWT_ISSUER!,108 WEB_EXT_API_SECRET: process.env.AMO_JWT_SECRET!,109 }110);111112113114console.log(`\n✓ Peach Firefox v${version} submitted to AMO.`);115console.log(` Source archive retained at ${sourceZip}.`);116console.log(" Existing users will receive the update automatically.");117console.log(" Check AMO developer hub for review status.");118console.log("");