Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.
Rust downloadmanagerguihacktoberfesthomebrewlightweightlinuxlinux-distributionlocal-firstmacosmacos-packagemedia-toolboxopen-sourcerustsveltetauritrendingtrending-repositorieswindowswindows-desktopytdlp
feat(chrome-extension): add packaging script and CI release job
InstaZDLLf16c405e8f6a
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex ea9304d7..08c2a635 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -87,6 +87,29 @@ jobs:}shell: pwsh+ package-chrome-extension:+ needs: publish-tauri+ runs-on: ubuntu-latest+ permissions:+ contents: write+ steps:+ - uses: actions/checkout@v4++ - name: Setup Node.js+ uses: actions/setup-node@v4+ with:+ node-version: lts/*++ - name: Package Chrome extension+ run: |+ TAG="${GITHUB_REF#refs/tags/}"+ VERSION="${TAG#v}"+ OUTPUT="omniget-chrome-extension-v${VERSION}.zip"+ node browser-extension/chrome/scripts/package.mjs --output "$OUTPUT"+ gh release upload "$TAG" "$OUTPUT" --repo "${{ github.repository }}" --clobber+ env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+upload-updater-json:needs: publish-tauriruns-on: ubuntu-latestdiff --git a/browser-extension/chrome/scripts/package.mjs b/browser-extension/chrome/scripts/package.mjsnew file mode 100644index 00000000..0b4333c5--- /dev/null+++ b/browser-extension/chrome/scripts/package.mjs@@ -0,0 +1,83 @@+#!/usr/bin/env node++/**+ * Packages the Chrome extension into a .zip ready for Chrome Web Store upload.+ *+ * Usage:+ * node browser-extension/chrome/scripts/package.mjs [--output path/to/output.zip]+ *+ * What it does:+ * 1. Copies browser-extension/chrome/ into a temp directory+ * 2. Strips the "key" field from manifest.json (CWS assigns its own)+ * 3. Removes dev-only files (tests/, scripts/, CHPR.md, README.md, package.json)+ * 4. Creates a .zip archive+ */++import { cpSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { basename, join, resolve } from "node:path";+import { tmpdir } from "node:os";+import { execSync } from "node:child_process";++const EXTENSION_DIR = resolve(import.meta.dirname, "..");++const DEV_ONLY = ["tests", "scripts", "CHPR.md", "README.md", "package.json"];++function parseArgs() {+ const args = process.argv.slice(2);+ const outputIndex = args.indexOf("--output");+ if (outputIndex !== -1 && args[outputIndex + 1]) {+ return { output: resolve(args[outputIndex + 1]) };+ }++ const manifest = JSON.parse(readFileSync(join(EXTENSION_DIR, "manifest.json"), "utf8"));+ return { output: resolve(`omniget-chrome-extension-v${manifest.version}.zip`) };+}++function stripManifestKey(dir) {+ const manifestPath = join(dir, "manifest.json");+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));+ delete manifest.key;+ writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + "\n");+}++function removeDevFiles(dir) {+ for (const name of DEV_ONLY) {+ const target = join(dir, name);+ rmSync(target, { recursive: true, force: true });+ }+}++function createZip(sourceDir, outputPath) {+ // Use tar on Unix-like systems, PowerShell on Windows+ if (process.platform === "win32") {+ execSync(+ `powershell -Command "Compress-Archive -Path '${sourceDir}\\*' -DestinationPath '${outputPath}' -Force"`,+ { stdio: "inherit" }+ );+ } else {+ execSync(`cd "${sourceDir}" && zip -r "${outputPath}" .`, { stdio: "inherit" });+ }+}++const { output } = parseArgs();++const tempDir = mkdtempSync(join(tmpdir(), "omniget-chrome-ext-"));+const stageDir = join(tempDir, "chrome");++try {+ console.log("Copying extension files...");+ cpSync(EXTENSION_DIR, stageDir, { recursive: true });++ console.log("Stripping manifest key...");+ stripManifestKey(stageDir);++ console.log("Removing dev-only files...");+ removeDevFiles(stageDir);++ console.log(`Creating ${basename(output)}...`);+ createZip(stageDir, output);++ console.log(`Done: ${output}`);+} finally {+ rmSync(tempDir, { recursive: true, force: true });+}