35bc480f3621

add web-ext sign script, source packaging, and one-command release (v3.6.93)

time
2026-05-23 21:03 UTC · 5 months ago
machine
koh2
parent
8293ed4e457e
3 files .kohignore+1 −0package.json+4 −1scripts/release-firefox.ts+108 −0
.kohignore+1 −0
@@ -12,3 +12,4 @@1212 tsconfig.tsbuildinfo1313 *.zip1414 *.crx15+artifacts/

view file

package.json+4 −1
@@ -15,7 +15,10 @@1515     "test": "vitest run",1616     "test:watch": "vitest",1717     "test:passkeys": "npm run build:e2e && playwright test tests/passkeys.spec.ts",18-    "ci": "bun run scripts/ci.ts"18+    "ci": "bun run scripts/ci.ts",19+    "package:source": "zip -r peach-source.zip src scripts public manifest.json manifest.firefox.json package.json package-lock.json tsconfig.json vite.config.ts vite.config.firefox.ts vite.config.chrome.ts vite.config.mobile.ts --exclude 'node_modules/*' --exclude 'dist-*/*' --exclude '*.zip'",20+    "release:firefox": "bun run scripts/release-firefox.ts",21+    "submit:firefox": "web-ext sign --source-dir dist-firefox --artifacts-dir artifacts --api-key=$AMO_JWT_ISSUER --api-secret=$AMO_JWT_SECRET --channel=listed"1922   },2023   "engines": {2124     "node": ">=26.0.0",

view file

scripts/release-firefox.ts+108 −0
@@ -0,0 +1,108 @@1+#!/usr/bin/env bun2+// scripts/release-firefox.ts3+// One-command Firefox AMO release.4+// Usage: bun run scripts/release-firefox.ts5+6+import { execSync } from "child_process";7+import { readFileSync, existsSync, mkdirSync } from "fs";8+import { join } from "path";9+10+const ROOT = process.cwd();11+12+function run(cmd: string, label?: string) {13+  const display = label ?? cmd;14+  console.log(`\n▶ ${display}`);15+  execSync(cmd, { stdio: "inherit", cwd: ROOT });16+}17+18+function fail(msg: string): never {19+  console.error(`\n✗ ${msg}`);20+  process.exit(1);21+}22+23+// ── Verify environment ────────────────────────────────────────────────────────24+25+if (!process.env.AMO_JWT_ISSUER) {26+  fail("AMO_JWT_ISSUER not set. Add it to your shell profile and reload.");27+}28+if (!process.env.AMO_JWT_SECRET) {29+  fail("AMO_JWT_SECRET not set. Add it to your shell profile and reload.");30+}31+32+// ── Read version ──────────────────────────────────────────────────────────────33+34+const manifest = JSON.parse(35+  readFileSync(join(ROOT, "manifest.firefox.json"), "utf8")36+);37+const version = manifest.version;38+if (!version) fail("Could not read version from manifest.firefox.json");39+console.log(`\n🍑 Peach Firefox — releasing v${version}`);40+41+// ── CI gate ───────────────────────────────────────────────────────────────────42+43+run("npm run ci", "Running CI gate");44+45+// ── Build ─────────────────────────────────────────────────────────────────────46+47+run("npm run build:firefox", `Building Firefox extension v${version}`);48+49+// ── Package source archive ────────────────────────────────────────────────────50+// AMO requires source for any extension with minified/transpiled code.51+// This zips everything a reviewer needs to build Peach from source.52+53+const sourceZip = `peach-source-${version}.zip`;54+run(55+  [56+    "zip -r",57+    sourceZip,58+    "src",59+    "scripts",60+    "public",61+    "manifest.json",62+    "manifest.firefox.json",63+    "package.json",64+    "package-lock.json",65+    "tsconfig.json",66+    "vite.config.ts",67+    "vite.config.firefox.ts",68+    "vite.config.chrome.ts",69+    "vite.config.mobile.ts",70+    "--exclude 'node_modules/*'",71+    "--exclude 'dist-*/*'",72+    "--exclude '*.zip'",73+    "--exclude '.DS_Store'",74+    "--exclude '__MACOSX/*'",75+  ].join(" "),76+  "Packaging source archive for AMO"77+);78+79+// ── Ensure artifacts dir ──────────────────────────────────────────────────────80+81+if (!existsSync(join(ROOT, "artifacts"))) {82+  mkdirSync(join(ROOT, "artifacts"));83+}84+85+// ── Sign and submit ───────────────────────────────────────────────────────────86+87+run(88+  [89+    "npx web-ext sign",90+    "--source-dir dist-firefox",91+    "--artifacts-dir artifacts",92+    `--api-key=${process.env.AMO_JWT_ISSUER}`,93+    `--api-secret=${process.env.AMO_JWT_SECRET}`,94+    "--channel=listed",95+  ].join(" "),96+  "Signing and submitting to AMO"97+);98+99+// ── Cleanup zip ───────────────────────────────────────────────────────────────100+101+run(`rm -f ${sourceZip}`, "Cleaning up source zip");102+103+// ── Done ──────────────────────────────────────────────────────────────────────104+105+console.log(`\n✓ Peach Firefox v${version} submitted to AMO.`);106+console.log("  Existing users will receive the update automatically.");107+console.log("  Check AMO developer hub for review status.");108+console.log("");

view file