feat: 集成 Tauri 更新插件并配置自动发布工作流

This commit is contained in:
Yuhang Wu
2026-10-14 10:03:22 +08:00
parent cdc9507209
commit f6d8d783b4
8 changed files with 168 additions and 2 deletions
+134
View File
@@ -0,0 +1,134 @@
name: "Publish Release"
on:
push:
tags:
- "v*" # 推送 v1.0.0 之类的 tag 时触发
workflow_dispatch: # 也支持手动触发
permissions:
contents: write # 需要写入权限来创建 Release
jobs:
publish-tauri:
strategy:
fail-fast: false
matrix:
include:
# macOS Apple Silicon (M1/M2/M3)
- platform: "macos-latest"
args: "--target aarch64-apple-darwin --bundles app,dmg"
# Windows x64
- platform: "windows-latest"
args: "--bundles nsis"
# Linux x64(用 22.04 以获得更宽的 glibc 兼容性)
- platform: "ubuntu-22.04"
args: "--bundles deb,appimage"
runs-on: ${{ matrix.platform }}
steps:
# 1. 检出代码
- name: Checkout
uses: actions/checkout@v5
# 2. 安装 pnpm(必须先于 setup-node 的 pnpm 缓存)
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 11
# 3. 安装 Node.js
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 24
cache: "pnpm"
# 4. 安装 Rust
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Add macOS Apple Silicon target
if: matrix.platform == 'macos-latest'
run: rustup target add aarch64-apple-darwin
# 4.1 安装 Linux 构建所需的系统依赖(WebKitGTK / GTK / OpenSSL 等)
- name: Install Linux dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev
# 5. Rust 缓存(大幅加速后续构建)
- name: Cache Rust build
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
# 6. 安装前端依赖
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
# 7. 从 docs/CHANGELOG.md 提取当前 tag 对应版本的更新日志
- name: Extract changelog for release
id: changelog
shell: bash
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
node -e '
const fs = require("fs");
const content = fs.readFileSync("docs/CHANGELOG.md", "utf8");
const lines = content.split(/\r?\n/);
const marker = "## " + process.env.RELEASE_TAG;
const startIdx = lines.findIndex((l) => l.trim().startsWith(marker));
if (startIdx === -1) {
fs.writeFileSync("release_body.md", "");
process.exit(0);
}
let endIdx = lines.length;
for (let i = startIdx + 1; i < lines.length; i++) {
if (/^##\s/.test(lines[i])) {
endIdx = i;
break;
}
}
fs.writeFileSync(
"release_body.md",
lines.slice(startIdx + 1, endIdx).join("\n").trim()
);
'
{
echo "body<<CHANGELOG_BODY_EOF"
cat release_body.md
# release_body.md is deliberately trimmed and may not end in a newline.
# Ensure the closing delimiter occupies its own line in GITHUB_OUTPUT.
printf '\nCHANGELOG_BODY_EOF\n'
} >> "$GITHUB_OUTPUT"
# 8. 构建并发布(核心步骤)
- name: Build app & publish release
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
tagName: v__VERSION__ # 自动替换为 src-tauri/tauri.conf.json(即 package.json)里的版本号
releaseName: "Frpilot v__VERSION__"
releaseBody: ${{ steps.changelog.outputs.body }}
releaseDraft: true # 先创建草稿,手动确认后再发布
prerelease: false
args: ${{ matrix.args }}
+1
View File
@@ -22,3 +22,4 @@ dist-ssr
*.njsproj
*.sln
*.sw?
.tauri
View File
+10 -1
View File
@@ -117,4 +117,13 @@ Layout布局content区域的磨砂玻璃卡片圆角样式我要改动一下:
- frpc服务启动后,还可以在下拉列表修改frpc版本,启动后就不能再修改版本,而且下拉列表里面要显示正在使用的frpc版本
- 切换菜单之后再切回仪表盘页面,实时日志内容没了,需要保持实时日志内容不会随页面切换而清空
#### 3.6 自动更新功能开发
#### 3.6 自动更新功能开发
- 设置页增加一个子页面(关于),里面内容是项目介绍、使用流程、GitHub地址、检查更新相关等内容
- 顶部栏增加一个检查更新图标操作按钮,按钮样式注意风格跟顶部栏统一
- 顶部栏再增加一个GitHub图标,点击跳转浏览器打开本项目GitHub地址
- 做一个更新弹窗,弹窗标题是最新版本号,以及一些说明性文字,例如:发现新版本啦等,语气尽量俏皮可爱,二次元语气。弹窗内容是更新日志,注意弹窗高度不能超过窗口高度的60%,如果更新日志内容过多,则在弹窗主内容区域内可以上下滚动。
- 弹窗底部是忽略该版本、取消、确认更新等操作
开发过程中使用到的组件尽可能全部使用Antdv库里面的,另外我引入的有tailwindcss原子化组件、auto-import和components依赖可以简化引入,开发之前尽可能先阅读一下package.json,看一下有哪些依赖可以简化代码开发
+2
View File
@@ -13,6 +13,8 @@
"@ant-design/icons-vue": "^7.0.1",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-process": "^2.4.0",
"@tauri-apps/plugin-updater": "^2.13.3",
"@vueuse/core": "^15.0.0",
"ant-design-vue": "^4.2.6",
"dayjs": "^1.11.23",
+20
View File
@@ -17,6 +17,12 @@ importers:
'@tauri-apps/plugin-opener':
specifier: ^2
version: 2.7.1
'@tauri-apps/plugin-process':
specifier: ^2.4.0
version: 2.4.0
'@tauri-apps/plugin-updater':
specifier: ^2.13.3
version: 2.13.3
'@vueuse/core':
specifier: ^15.0.0
version: 15.0.0(vue@3.5.43(typescript@6.0.3))
@@ -529,6 +535,12 @@ packages:
'@tauri-apps/plugin-opener@2.7.1':
resolution: {integrity: sha512-XkXdt30rontti9TII/gBBxFRXWfj8DiprFW7RgBFRBj1OhdfjBNVcFqSEWkkZ4hXafHnuEnB7F1sFsmu6uyywQ==}
'@tauri-apps/plugin-process@2.4.0':
resolution: {integrity: sha512-GddrmsSLAYrLa/yTXlXK/YRDzUgYeeOnUXTbiyvJWkmI424RmDPD3FVLeqcon7rv6O6ZfhBilcrHWnSo7o6hIQ==}
'@tauri-apps/plugin-updater@2.13.3':
resolution: {integrity: sha512-CtbA8CZ79WJry2HbRiFGx6WZN7uspho6A4jM+TxmuqwWL2EEfJEMw6BIYgRncIZyqp4vEXw3U/97ZjQ33dKUgg==}
'@types/estree@1.0.9':
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
@@ -1543,6 +1555,14 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.12.3
'@tauri-apps/plugin-process@2.4.0':
dependencies:
'@tauri-apps/api': 2.12.3
'@tauri-apps/plugin-updater@2.13.3':
dependencies:
'@tauri-apps/api': 2.12.3
'@types/estree@1.0.9': {}
'@types/node@26.6.5':
+1 -1
View File
@@ -41,7 +41,7 @@
"active": true,
"dialog": true,
"endpoints": ["https://ghproxy.net/https://github.com/SparksFly91/Frpilot/releases/latest/download/latest.json"],
"pubkey": ""
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU0REVGMTREODFFOTI2MUEKUldRYUp1bUJUZkhlNU1qRmlPQm5xSmdQd24waFltVmNtTjlUallYVmdva1VGNkp5bTVGcVlsZUgK"
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 676 KiB