Skip to content

Commit ebcc959

Browse files
authored
Merge pull request #4 from erduotong/develop
一些工作流
2 parents 948924b + d1808fb commit ebcc959

File tree

14 files changed

+163
-41
lines changed

14 files changed

+163
-41
lines changed

.github/scripts/nightlyBuildProcess.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @fileOverview 处理nightlyBuild的数据
3+
*/
4+
5+
const fs = require("fs");
6+
const toml = require("@iarna/toml");
7+
8+
const cargoPath = "App/src-tauri/Cargo.toml";
9+
10+
try {
11+
if (!fs.existsSync(cargoPath)) {
12+
throw new Error(`配置文件不存在: ${cargoPath}`);
13+
}
14+
15+
const tomlObject = toml.parse(fs.readFileSync(cargoPath, "utf-8"));
16+
const {
17+
release,
18+
releaseFrontend,
19+
} = tomlObject.package.metadata.loglevel;
20+
21+
Object.assign(tomlObject.package.metadata.loglevel, {
22+
release: "trace",
23+
releaseFrontend: "trace",
24+
});
25+
26+
console.log(
27+
`日志级别已更新: release(${
28+
release || "未设置"
29+
} -> trace), releaseFrontend(${releaseFrontend || "未设置"} -> trace)`,
30+
);
31+
32+
fs.writeFileSync(cargoPath, toml.stringify(tomlObject));
33+
console.log("✅ 配置更新完成");
34+
} catch (error) {
35+
console.error("❌ 错误:", error.message);
36+
process.exit(1);
37+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @fileOverview 处理应用程序的版本号 需要用--version版本号
3+
*/
4+
const fs = require("fs");
5+
const toml = require("@iarna/toml");
6+
const path = require("path");
7+
8+
const PATHS = {
9+
PACKAGE: path.resolve("App/package.json"),
10+
TAURI: path.resolve("App/src-tauri/tauri.conf.json"),
11+
CARGO: path.resolve("App/src-tauri/Cargo.toml"),
12+
};
13+
14+
// 获取命令行参数中的版本号
15+
const args = process.argv.slice(2);
16+
const versionArg = args.find((arg) => arg.startsWith("--version="));
17+
18+
if (!versionArg) {
19+
console.error("请提供版本号参数,例如: --version=1.0.0");
20+
process.exit(1);
21+
}
22+
23+
const newVersion = versionArg.split("=")[1];
24+
25+
// 更新package.json
26+
try {
27+
console.log("📦 正在更新 package.json");
28+
const packageJson = JSON.parse(fs.readFileSync(PATHS.PACKAGE, "utf-8"));
29+
packageJson.version = newVersion;
30+
fs.writeFileSync(PATHS.PACKAGE, JSON.stringify(packageJson, null, 2));
31+
console.log("✅ package.json 更新成功");
32+
} catch (error) {
33+
console.error("❌ 更新 package.json 失败:", error.message);
34+
process.exit(1);
35+
}
36+
37+
// 更新tauri.conf.json
38+
try {
39+
console.log("🔧 正在更新 tauri.conf.json");
40+
const tauriJson = JSON.parse(fs.readFileSync(PATHS.TAURI, "utf-8"));
41+
tauriJson.version = newVersion;
42+
fs.writeFileSync(PATHS.TAURI, JSON.stringify(tauriJson, null, 2));
43+
console.log("✅ tauri.conf.json 更新成功");
44+
} catch (error) {
45+
console.error("❌ 更新 tauri.conf.json 失败:", error.message);
46+
process.exit(1);
47+
}
48+
49+
// 更新Cargo.toml
50+
try {
51+
console.log("📦 正在更新 Cargo.toml");
52+
const cargoContent = fs.readFileSync(PATHS.CARGO, "utf-8");
53+
const cargoData = toml.parse(cargoContent);
54+
cargoData.package.version = newVersion;
55+
fs.writeFileSync(PATHS.CARGO, toml.stringify(cargoData));
56+
console.log("✅ Cargo.toml 更新成功");
57+
} catch (error) {
58+
console.error("❌ 更新 Cargo.toml 失败:", error.message);
59+
process.exit(1);
60+
}
61+
62+
console.log("🎉 版本更新完成!");

.github/workflows/Nightly Build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
workspaces: "./App/src-tauri -> target"
3535
# 数据处理
3636
- name: set loglevel
37-
run: node .github/scripts/nightlyBuildProcess.js
37+
run: node .github/scripts/processLoglevelToTrace.js
3838
# Build
3939
- name: Build
4040
run: pnpm --filter @techclass/app tauri build
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 发布准备
2+
on:
3+
create:
4+
branches:
5+
- "release/*"
6+
jobs:
7+
prepare:
8+
name: 发布准备
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: checkout
12+
uses: actions/checkout@v4
13+
- uses: pnpm/action-setup@v4
14+
name: Install pnpm
15+
with:
16+
version: 8
17+
run_install: false
18+
- name: setup Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: lts/*
22+
cache: "pnpm"
23+
- name: install dependencies
24+
run: pnpm install
25+
- name: 获得版本号
26+
id: get_version
27+
shell: pwsh
28+
run: |
29+
$branchName = git branch --show-current
30+
$version = $branchName -replace '^release/', ''
31+
if ($version -notmatch '^\d+\.\d+\.\d+$') {
32+
Write-Error "版本号格式不正确,应为 x.y.z 格式,其中 x、y、z 均为数字"
33+
exit 1
34+
}
35+
Write-Host "检测到版本号: $version"
36+
"VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Append
37+
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
38+
- name: 更新版本号
39+
run: node .github/scripts/updateAppVersion.js --version=${{ env.VERSION }}
40+

App/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@tauri-apps/plugin-shell": "^2",
1919
"@types/lodash": "^4.17.13",
2020
"lodash": "^4.17.21",
21+
"lucide-vue-next": "^0.477.0",
2122
"luxon": "^3.5.0",
2223
"markdown-it": "^14.1.0",
2324
"pinia": "^2.2.6",

App/src/assets/images/settings.svg

Lines changed: 0 additions & 6 deletions
This file was deleted.

App/src/assets/images/web-window-close.svg

Lines changed: 0 additions & 4 deletions
This file was deleted.

App/src/components/SettingPage.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {computed, defineComponent, markRaw, watch} from "vue";
66
import PluginSet from "./setting/PluginSet.vue";
77
import {computedPluginsComponent} from "../modules/pluginUtils";
88
import {PluginStore} from "../types/plugins.types";
9+
import {CircleX} from "lucide-vue-next";
910
1011
const store = useApplicationStore();
1112
@@ -88,11 +89,7 @@ watch(
8889
class="absolute top-1 right-1 m-2 w-8 h-8 hover:bg-gray-200 rounded-full transition-all duration-200 flex items-center justify-center"
8990
@click="store.reverseSettingOpen()"
9091
>
91-
<img
92-
alt="关闭窗口"
93-
src="../assets/images/web-window-close.svg"
94-
class="w-6 h-6"
95-
/>
92+
<CircleX />
9693
</button>
9794

9895
<div

App/src/components/SideDock.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<script lang="ts" setup>
22
import {useApplicationStore} from "../stores/useApplicationStore";
3+
import {Settings} from "lucide-vue-next"
34
45
const store = useApplicationStore();
56
</script>
67

78
<template>
89
<div class="w-[40px] bg-gray-200 h-dvh flex flex-col p-1 shadow-md">
910
<div></div>
10-
<button class="p-1 mt-auto hover:bg-gray-300 rounded-lg transition-colors"
11+
<button class="p-1 mt-auto hover:bg-gray-300 rounded-lg transition-colors"
1112
@click="store.reverseSettingOpen()">
12-
<img alt="设置页面" src="../assets/images/settings.svg"
13-
class="opacity-70 hover:opacity-100 transition-opacity">
13+
<Settings class="opacity-70 hover:opacity-100 transition-opacity" />
1414
</button>
1515
</div>
1616
</template>

0 commit comments

Comments
 (0)