feat: add scripts for managing alpha versioning and update workflow

This commit is contained in:
Tunglies 2025-03-22 05:11:32 +08:00
parent 90f99a3879
commit 85124549d7
4 changed files with 51 additions and 1 deletions

View File

@ -246,6 +246,9 @@ jobs:
pnpm i
pnpm check ${{ matrix.target }}
- name: Release Alpha Version
pnpm release-alpha-version
- name: Tauri build
uses: tauri-apps/tauri-action@v0
env:
@ -312,6 +315,9 @@ jobs:
pnpm i
pnpm check ${{ matrix.target }}
- name: Release Alpha Version
pnpm release-alpha-version
- name: "Setup for linux"
run: |-
sudo ls -lR /etc/apt/
@ -432,6 +438,9 @@ jobs:
pnpm i
pnpm check ${{ matrix.target }}
- name: Release Alpha Version
pnpm release-alpha-version
- name: Download WebView2 Runtime
run: |
invoke-webrequest -uri https://github.com/westinyang/WebView2RuntimeArchive/releases/download/109.0.1518.78/Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab -outfile Microsoft.WebView2.FixedVersionRuntime.109.0.1518.78.${{ matrix.arch }}.cab

View File

@ -16,7 +16,8 @@
"updater-fixed-webview2": "node scripts/updater-fixed-webview2.mjs",
"portable": "node scripts/portable.mjs",
"portable-fixed-webview2": "node scripts/portable-fixed-webview2.mjs",
"fix-alpha-version": "node scripts/alpha_version.mjs",
"fix-alpha-version": "node scripts/fix-alpha_version.mjs",
"release-alpha-version": "node scripts/release-alpha_version.mjs",
"prepare": "husky",
"clean": "cd ./src-tauri && cargo clean && cd -"
},

View File

@ -0,0 +1,40 @@
import fs from "fs/promises";
import path from "path";
/**
* @param string 传入格式化后的hash
* 将新的版本号写入文件 package.json
*/
async function updatePackageVersion() {
// 获取内容根目录
const _dirname = process.cwd();
const packageJsonPath = path.join(_dirname, "package.json");
try {
// 读取文件
const data = await fs.readFile(packageJsonPath, "utf8");
const packageJson = JSON.parse(data);
let result = packageJson.version;
const newVersion = result;
// Check if version includes 'alpha'
if (!result.includes("alpha")) {
// If not, append -alpha to the version
result = `${result}-alpha`;
}
console.log("[INFO]: Current version is: ", result);
packageJson.version = result;
// 写入版本号
await fs.writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2),
"utf8",
);
console.log(`[INFO]: Alpha version update to: ${newVersion}`);
} catch (error) {
console.error("pnpm run fix-alpha-version ERROR", error);
}
}
updatePackageVersion().catch(console.error);