fix: update alpha and release workflows to trigger builds via git tags only
feat: update release workflow to trigger builds via git tags and add publish version script
This commit is contained in:
5
.github/workflows/alpha.yml
vendored
5
.github/workflows/alpha.yml
vendored
@@ -1,7 +1,10 @@
|
|||||||
name: Alpha Build
|
name: Alpha Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
# 因为 alpha 不再负责频繁构建,且需要相对于 autobuild 更稳定使用环境
|
||||||
|
# 所以不再使用 workflow_dispatch 触发
|
||||||
|
# 应当通过 git tag 来触发构建
|
||||||
|
# workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*-alpha*"
|
- "v*.*.*-alpha*"
|
||||||
|
|||||||
15
.github/workflows/release.yml
vendored
15
.github/workflows/release.yml
vendored
@@ -1,7 +1,15 @@
|
|||||||
name: Release Build
|
name: Release Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
# ! 为了避免重复发布版本,应当通过独特 git tag 触发。
|
||||||
|
# ! 不再使用 workflow_dispatch 触发。
|
||||||
|
# workflow_dispatch:
|
||||||
|
push:
|
||||||
|
# ? 应当限制在 main 分支上触发发布。
|
||||||
|
# branches:
|
||||||
|
# - main
|
||||||
|
tags:
|
||||||
|
- "v*.*.*"
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
env:
|
env:
|
||||||
CARGO_INCREMENTAL: 0
|
CARGO_INCREMENTAL: 0
|
||||||
@@ -13,6 +21,7 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
name: Release Build
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -88,6 +97,7 @@ jobs:
|
|||||||
args: --target ${{ matrix.target }}
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
release-for-linux-arm:
|
release-for-linux-arm:
|
||||||
|
name: Release Build for Linux ARM
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -209,6 +219,7 @@ jobs:
|
|||||||
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
src-tauri/target/${{ matrix.target }}/release/bundle/rpm/*.rpm
|
||||||
|
|
||||||
release-for-fixed-webview2:
|
release-for-fixed-webview2:
|
||||||
|
name: Release Build for Fixed WebView2
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -303,6 +314,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
release-update:
|
release-update:
|
||||||
|
name: Release Update
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [release, release-for-linux-arm]
|
needs: [release, release-for-linux-arm]
|
||||||
steps:
|
steps:
|
||||||
@@ -353,6 +365,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
submit-to-winget:
|
submit-to-winget:
|
||||||
|
name: Submit to Winget
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [release-update]
|
needs: [release-update]
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -18,10 +18,18 @@ A Clash Meta GUI based on <a href="https://github.com/tauri-apps/tauri">Tauri</a
|
|||||||
## Install
|
## Install
|
||||||
|
|
||||||
请到发布页面下载对应的安装包:[Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases)<br>
|
请到发布页面下载对应的安装包:[Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases)<br>
|
||||||
Go to the [release page](https://github.com/clash-verge-rev/clash-verge-rev/releases) to download the corresponding installation package<br>
|
Go to the [Release page](https://github.com/clash-verge-rev/clash-verge-rev/releases) to download the corresponding installation package<br>
|
||||||
Supports Windows (x64/x86), Linux (x64/arm64) and macOS 10.15+ (intel/apple).
|
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/) 查看
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "clash-verge",
|
"name": "clash-verge",
|
||||||
"version": "2.3.0-alpha.0",
|
"version": "2.3.0-alpha",
|
||||||
"license": "GPL-3.0-only",
|
"license": "GPL-3.0-only",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",
|
"dev": "cross-env RUST_BACKTRACE=1 tauri dev -f verge-dev",
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
"portable-fixed-webview2": "node scripts/portable-fixed-webview2.mjs",
|
"portable-fixed-webview2": "node scripts/portable-fixed-webview2.mjs",
|
||||||
"fix-alpha-version": "node scripts/fix-alpha_version.mjs",
|
"fix-alpha-version": "node scripts/fix-alpha_version.mjs",
|
||||||
"release-version": "node scripts/release-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",
|
"prepare": "husky",
|
||||||
"fmt": "cargo fmt --manifest-path ./src-tauri/Cargo.toml",
|
"fmt": "cargo fmt --manifest-path ./src-tauri/Cargo.toml",
|
||||||
"clippy": "cargo clippy --manifest-path ./src-tauri/Cargo.toml"
|
"clippy": "cargo clippy --manifest-path ./src-tauri/Cargo.toml"
|
||||||
|
|||||||
64
scripts/publish-version.mjs
Normal file
64
scripts/publish-version.mjs
Normal file
@@ -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 <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();
|
||||||
Reference in New Issue
Block a user