diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index 7322613..e2ef987 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -96,3 +96,10 @@ jobs: releaseBody: "Alpha Version" releaseDraft: false prerelease: true + + - name: Portable Bundle For Meta + if: matrix.os == 'windows-latest' + run: | + yarn run portable --meta + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/portable.mjs b/scripts/portable.mjs index 932abc5..1d1338b 100644 --- a/scripts/portable.mjs +++ b/scripts/portable.mjs @@ -4,6 +4,8 @@ import AdmZip from "adm-zip"; import { createRequire } from "module"; import { getOctokit, context } from "@actions/github"; +const META = process.argv.includes("--meta"); // use Clash.Meta + /// Script for ci /// 打包绿色版/便携版 (only Windows) async function resolvePortable() { @@ -53,4 +55,54 @@ async function resolvePortable() { }); } -resolvePortable().catch(console.error); +/// 打包包含Clash.Meta的 (only Windows) +async function resolvePortableMeta() { + if (process.platform !== "win32") return; + + const releaseDir = "./src-tauri/target/release"; + + if (!(await fs.pathExists(releaseDir))) { + throw new Error("could not found the release dir"); + } + + const zip = new AdmZip(); + + zip.addLocalFile(path.join(releaseDir, "Clash Verge.exe")); + zip.addLocalFile(path.join(releaseDir, "clash.exe")); + zip.addLocalFile(path.join(releaseDir, "clash-meta.exe")); + zip.addLocalFolder(path.join(releaseDir, "resources"), "resources"); + + const require = createRequire(import.meta.url); + const packageJson = require("../package.json"); + const { version } = packageJson; + + const zipFile = `Clash.Verge.Meta_${version}_x64_portable.zip`; + zip.writeZip(zipFile); + + console.log("[INFO]: create portable zip successfully"); + + // push release assets + if (process.env.GITHUB_TOKEN === undefined) { + throw new Error("GITHUB_TOKEN is required"); + } + + const options = { owner: context.repo.owner, repo: context.repo.repo }; + const github = getOctokit(process.env.GITHUB_TOKEN); + + const { data: release } = await github.rest.repos.getReleaseByTag({ + ...options, + tag: `v${version}`, + }); + + console.log(release.name); + + await github.rest.repos.uploadReleaseAsset({ + ...options, + release_id: release.id, + name: zipFile, + data: zip.toBuffer(), + }); +} + +if (META) resolvePortableMeta().catch(console.error); +else resolvePortable().catch(console.error); diff --git a/src-tauri/tauri.meta.json b/src-tauri/tauri.meta.json index 9f4bb77..6720a58 100644 --- a/src-tauri/tauri.meta.json +++ b/src-tauri/tauri.meta.json @@ -1,7 +1,87 @@ { + "package": { + "productName": "Clash Verge Meta", + "version": "1.0.1" + }, + "build": { + "distDir": "../dist", + "devPath": "http://localhost:3000/", + "beforeDevCommand": "yarn run web:dev", + "beforeBuildCommand": "yarn run web:build" + }, "tauri": { + "systemTray": { + "iconPath": "icons/tray-icon.png", + "iconAsTemplate": true + }, "bundle": { - "externalBin": ["sidecar/clash", "sidecar/clash-meta"] + "active": true, + "targets": "all", + "identifier": "top.gydi.clashverge", + "icon": [ + "icons/32x32.png", + "icons/128x128.png", + "icons/128x128@2x.png", + "icons/icon.icns", + "icons/icon.ico" + ], + "resources": ["resources"], + "externalBin": ["sidecar/clash", "sidecar/clash-meta"], + "copyright": "© 2022 zzzgydi All Rights Reserved", + "category": "DeveloperTool", + "shortDescription": "A Clash GUI based on tauri.", + "longDescription": "A Clash GUI based on tauri.", + "deb": { + "depends": [] + }, + "macOS": { + "frameworks": [], + "minimumSystemVersion": "", + "exceptionDomain": "", + "signingIdentity": null, + "entitlements": null + }, + "windows": { + "certificateThumbprint": null, + "digestAlgorithm": "sha256", + "timestampUrl": "" + } + }, + "updater": { + "active": true, + "endpoints": [ + "https://github.com/zzzgydi/clash-verge/releases/download/updater/update.json", + "https://hub.fastgit.xyz/zzzgydi/clash-verge/releases/download/updater/update-proxy.json" + ], + "dialog": false, + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDExNUFBNTBBN0FDNEFBRTUKUldUbHFzUjZDcVZhRVRJM25NS3NkSFlFVElxUkNZMzZ6bHUwRVJjb2F3alJXVzRaeDdSaTA2YWYK" + }, + "allowlist": { + "shell": { + "all": true + }, + "window": { + "all": true + }, + "process": { + "all": true + } + }, + "windows": [ + { + "title": "Clash Verge", + "width": 800, + "height": 636, + "resizable": true, + "fullscreen": false, + "decorations": false, + "transparent": true, + "minWidth": 600, + "minHeight": 520 + } + ], + "security": { + "csp": "script-src 'unsafe-eval' 'self'; default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self'; img-src data: 'self';" } } }