From 9bb2160abeb90a6bde07732b18fa3015a1f9ea96 Mon Sep 17 00:00:00 2001 From: "Christine." Date: Mon, 3 Mar 2025 01:16:33 +0800 Subject: [PATCH] workflow: remove 32-bit platform (#2855) * chore: build portable by self * chore: remove 32bit platform * Update CONTRIBUTING.md * update alpha version --- .github/workflows/alpha.yml | 8 +----- .github/workflows/release.yml | 9 ------- CONTRIBUTING.md | 14 ++++++++--- package.json | 2 +- scripts/alpha_version.mjs | 26 ++++++++++++++------ scripts/portable.mjs | 46 ++--------------------------------- src-tauri/tauri.conf.json | 2 +- 7 files changed, 35 insertions(+), 72 deletions(-) diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index d2add9cf..c52fe0f5 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -92,12 +92,6 @@ jobs: tauriScript: pnpm args: --target ${{ matrix.target }} - - name: Portable Bundle - if: matrix.os == 'windows-latest' - run: pnpm portable ${{ matrix.target }} --alpha - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - alpha-for-linux-arm: strategy: fail-fast: false @@ -347,7 +341,7 @@ jobs: - Linux arm64 architecture: arm64.deb/aarch64.rpm - Linux armv7架构: armhf.deb/armhfp.rpm - ### Windows (Win7 用户请查看下面FAQ中的解决方案) + ### Windows (不再支持Win7) #### 正常版本(推荐) - 64位: x64-setup.exe - arm64架构: arm64-setup.exe diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36c34eca..4ad137ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,12 +87,6 @@ jobs: tauriScript: pnpm args: --target ${{ matrix.target }} - - name: Portable Bundle - if: matrix.os == 'windows-latest' - run: pnpm portable ${{ matrix.target }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - release-for-linux-arm: strategy: fail-fast: false @@ -221,9 +215,6 @@ jobs: - os: windows-latest target: x86_64-pc-windows-msvc arch: x64 - - os: windows-latest - target: i686-pc-windows-msvc - arch: x86 - os: windows-latest target: aarch64-pc-windows-msvc arch: arm64 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a9dd2ee6..02c3c9cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -38,7 +38,7 @@ npm install pnpm -g pnpm install ``` -### Download the Clash Mihomo Core Binary +### Download the Mihomo Core Binary You have two options for downloading the clash binary: @@ -48,7 +48,7 @@ You have two options for downloading the clash binary: # Use '--force' to force update to the latest version # pnpm run check --force ``` -- Manually download it from the [Clash Meta release](https://github.com/MetaCubeX/Clash.Meta/releases). After downloading, rename the binary according to the [Tauri configuration](https://tauri.app/v1/api/config#bundleconfig.externalbin). +- Manually download it from the [Mihomo release](https://github.com/MetaCubeX/mihomo/releases). After downloading, rename the binary according to the [Tauri configuration](https://tauri.app/v1/api/config#bundleconfig.externalbin). ### Run the Development Server @@ -65,7 +65,7 @@ pnpm dev:diff To build this project: ```shell -pnpm run build +pnpm build ``` For a faster build, use the following command @@ -86,6 +86,14 @@ To clean rust build: pnpm clean ``` +### Portable Version (Windows Only) + +To package portable version after the build: + +```shell +pnpm portable +``` + ## Contributing Your Changes Once you have made your changes: diff --git a/package.json b/package.json index 8094f52e..9687242a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clash-verge", - "version": "2.1.3", + "version": "2.1.3-alpha", "license": "GPL-3.0-only", "scripts": { "dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev -- --profile fast-dev", diff --git a/scripts/alpha_version.mjs b/scripts/alpha_version.mjs index 15be5759..ce5a303d 100644 --- a/scripts/alpha_version.mjs +++ b/scripts/alpha_version.mjs @@ -26,29 +26,41 @@ async function getLatestCommitHash() { /** * @param string 传入格式化后的hash - * 将新的版本号写入文件 package.json + * 将新的版本号写入文件 package.json / tauri.conf.json */ async function updatePackageVersion(newVersion) { // 获取内容根目录 const _dirname = process.cwd(); const packageJsonPath = path.join(_dirname, "package.json"); + const tauriDir = path.join(_dirname, "src-tauri"); + const internalfile = path.join(tauriDir, "tauri.conf.json"); try { const data = await fs.readFile(packageJsonPath, "utf8"); + const tauriData = await fs.readFile(internalfile, "utf8"); + const packageJson = JSON.parse(data); - const initversion = packageJson.version; - // 将匹配到的第一个 "alpha" => 具体的hash - const fixversion = initversion.replace("alpha", newVersion); - packageJson.version = fixversion; + const tauriJson = JSON.parse(tauriData); + + let result = packageJson.version.replace("alpha", newVersion); + console.log("[INFO]: Current version is: ", result); + packageJson.version = result; + tauriJson.version = result; // 写入版本号 await fs.writeFile( packageJsonPath, JSON.stringify(packageJson, null, 2), "utf8", ); - console.log(`Alpha version update to: ${fixversion}`); + await fs.writeFile( + internalfile, + JSON.stringify(tauriJson, null, 2), + "utf8", + ); + console.log(`[INFO]: Alpha version update to: ${newVersion}`); } catch (error) { console.error("pnpm run fix-alpha-version ERROR", error); } } + const newVersion = await getLatestCommitHash(); -updatePackageVersion(newVersion); +updatePackageVersion(newVersion).catch(console.error); diff --git a/scripts/portable.mjs b/scripts/portable.mjs index 97a00d4a..49aafdb9 100644 --- a/scripts/portable.mjs +++ b/scripts/portable.mjs @@ -2,20 +2,16 @@ import fs from "fs"; import path from "path"; import AdmZip from "adm-zip"; import { createRequire } from "module"; -import { getOctokit, context } from "@actions/github"; +import fsp from "fs/promises"; const target = process.argv.slice(2)[0]; -const alpha = process.argv.slice(2)[1]; - const ARCH_MAP = { "x86_64-pc-windows-msvc": "x64", - "i686-pc-windows-msvc": "x86", "aarch64-pc-windows-msvc": "arm64", }; const PROCESS_MAP = { x64: "x64", - ia32: "x86", arm64: "arm64", }; const arch = target ? ARCH_MAP[target] : PROCESS_MAP[process.arch]; @@ -37,10 +33,9 @@ async function resolvePortable() { if (!fs.existsSync(path.join(configDir, "PORTABLE"))) { await fsp.writeFile(path.join(configDir, "PORTABLE"), ""); } - const zip = new AdmZip(); - zip.addLocalFile(path.join(releaseDir, "Clash Verge.exe")); + zip.addLocalFile(path.join(releaseDir, "clash-verge.exe")); zip.addLocalFile(path.join(releaseDir, "verge-mihomo.exe")); zip.addLocalFile(path.join(releaseDir, "verge-mihomo-alpha.exe")); zip.addLocalFolder(path.join(releaseDir, "resources"), "resources"); @@ -49,46 +44,9 @@ async function resolvePortable() { const require = createRequire(import.meta.url); const packageJson = require("../package.json"); const { version } = packageJson; - const zipFile = `Clash.Verge_${version}_${arch}_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 tag = alpha ? "alpha" : process.env.TAG_NAME || `v${version}`; - console.log("[INFO]: upload to ", tag); - - const { data: release } = await github.rest.repos.getReleaseByTag({ - ...options, - tag, - }); - - let assets = release.assets.filter((x) => { - return x.name === zipFile; - }); - if (assets.length > 0) { - let id = assets[0].id; - await github.rest.repos.deleteReleaseAsset({ - ...options, - asset_id: id, - }); - } - - console.log(release.name); - - await github.rest.repos.uploadReleaseAsset({ - ...options, - release_id: release.id, - name: zipFile, - data: zip.toBuffer(), - }); } resolvePortable().catch(console.error); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c91523cf..5f9e182b 100755 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,5 +1,5 @@ { - "version": "2.1.3", + "version": "2.1.3-alpha", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "bundle": { "active": true,