diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index 086b1859..87646179 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -1,7 +1,10 @@ name: Alpha Build on: - workflow_dispatch: + # 因为 alpha 不再负责频繁构建,且需要相对于 autobuild 更稳定使用环境 + # 所以不再使用 workflow_dispatch 触发 + # 应当通过 git tag 来触发构建 + # workflow_dispatch: push: tags: - "v*.*.*-alpha*" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4eacd166..8372eeee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,15 @@ name: Release Build on: - workflow_dispatch: + # ! 为了避免重复发布版本,应当通过独特 git tag 触发。 + # ! 不再使用 workflow_dispatch 触发。 + # workflow_dispatch: + push: + # ? 应当限制在 main 分支上触发发布。 + # branches: + # - main + tags: + - "v*.*.*" permissions: write-all env: CARGO_INCREMENTAL: 0 @@ -13,6 +21,7 @@ concurrency: jobs: release: + name: Release Build strategy: fail-fast: false matrix: @@ -88,6 +97,7 @@ jobs: args: --target ${{ matrix.target }} release-for-linux-arm: + name: Release Build for Linux ARM strategy: fail-fast: false matrix: @@ -209,6 +219,7 @@ jobs: src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm release-for-fixed-webview2: + name: Release Build for Fixed WebView2 strategy: fail-fast: false matrix: @@ -303,6 +314,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} release-update: + name: Release Update runs-on: ubuntu-latest needs: [release, release-for-linux-arm] steps: @@ -353,6 +365,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} submit-to-winget: + name: Submit to Winget runs-on: ubuntu-latest needs: [release-update] steps: diff --git a/README.md b/README.md index e8d425f5..724674f7 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,18 @@ A Clash Meta GUI based on Tauri -Go to the [release page](https://github.com/clash-verge-rev/clash-verge-rev/releases) to download the corresponding installation package
+Go to the [Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases) to download the corresponding installation package
Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple). -### 安装说明和常见问题,请到[文档页](https://clash-verge-rev.github.io/)查看:[Doc](https://clash-verge-rev.github.io/) +#### 我应当怎样选择发行版 + +| 版本 | 特征 | 链接 | +|:-----|:-----|:-----| +|Stable|正式版,高可靠性,适合日常使用。|[Release](https://github.com/clash-verge-rev/clash-verge-rev/releases) | +|Alpha|早期测试版,功能未完善,可能存在缺陷。|[Alpha](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/alpha)| +|AutoBuild|滚动更新版,持续集成更新,适合开发测试。|[AutoBuild](https://github.com/clash-verge-rev/clash-verge-rev/releases/tag/autobuild)| + +#### 安装说明和常见问题,请到 [文档页](https://clash-verge-rev.github.io/) 查看 --- diff --git a/package.json b/package.json index 37eabe1a..7bdb9e4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clash-verge", - "version": "2.3.0-alpha.0", + "version": "2.3.0-alpha", "license": "GPL-3.0-only", "scripts": { "dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev", @@ -18,7 +18,7 @@ "portable-fixed-webview2": "node scripts/portable-fixed-webview2.mjs", "fix-alpha-version": "node scripts/fix-alpha_version.mjs", "release-version": "node scripts/release-version.mjs", - "release-alpha-version": "node scripts/release-alpha_version.mjs", + "publish-version": "node scripts/publish-version.mjs", "prepare": "husky", "fmt": "cargo fmt --manifest-path ./src-tauri/Cargo.toml", "clippy": "cargo clippy --manifest-path ./src-tauri/Cargo.toml" diff --git a/scripts/publish-version.mjs b/scripts/publish-version.mjs new file mode 100644 index 00000000..617e38bf --- /dev/null +++ b/scripts/publish-version.mjs @@ -0,0 +1,64 @@ +// scripts/publish-version.mjs +import { spawn } from "child_process"; +import { existsSync } from "fs"; +import path from "path"; + +const rootDir = process.cwd(); +const scriptPath = path.join(rootDir, "scripts", "release-version.mjs"); + +if (!existsSync(scriptPath)) { + console.error("release-version.mjs not found!"); + process.exit(1); +} + +const versionArg = process.argv[2]; +if (!versionArg) { + console.error("Usage: pnpm publish-version "); + process.exit(1); +} + +// 1. 调用 release-version.mjs +const runRelease = () => + new Promise((resolve, reject) => { + const child = spawn("node", [scriptPath, versionArg], { stdio: "inherit" }); + child.on("exit", (code) => { + if (code === 0) resolve(); + else reject(new Error("release-version failed")); + }); + }); + +// 2. 判断是否需要打 tag +function isSemver(version) { + return /^v?\d+\.\d+\.\d+(-alpha)?$/.test(version); +} + +async function run() { + await runRelease(); + + let tag = null; + if (versionArg === "alpha") { + // 读取 package.json 里的主版本 + const pkg = await import(path.join(rootDir, "package.json"), { assert: { type: "json" } }); + tag = `v${pkg.default.version}-alpha`; + } else if (isSemver(versionArg)) { + // 1.2.3 或 v1.2.3 + tag = versionArg.startsWith("v") ? versionArg : `v${versionArg}`; + } + + if (tag) { + // 打 tag 并推送 + const { execSync } = await import("child_process"); + try { + execSync(`git tag ${tag}`, { stdio: "inherit" }); + execSync(`git push origin ${tag}`, { stdio: "inherit" }); + console.log(`[INFO]: Git tag ${tag} created and pushed.`); + } catch (e) { + console.error(`[ERROR]: Failed to create or push git tag: ${tag}`); + process.exit(1); + } + } else { + console.log("[INFO]: No git tag created for this version."); + } +} + +run(); \ No newline at end of file