Skip to content

Commit f4b2ecb

Browse files
author
FasterEdge
committed
chore(ci): merge main into dependabot/npm_and_yarn/vue-tsc-3.3.11
Bring the PR branch up to date with main so PR CI runs the fixed workflows. Resolved: package-lock.json
2 parents a89c2cc + 1794cc6 commit f4b2ecb

4 files changed

Lines changed: 539 additions & 326 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 194 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,217 @@
11
name: '跨平台 Release 打包'
2+
3+
# 触发时机:
4+
# 1. 用户在 GitHub 上「发布」一个版本(Release published / 从草稿发布)——主路径;
5+
# 2. 推送 v* 标签;
6+
# 3. 手动触发(可指定标签)。
7+
# 4. main/master 分支推送或 PR:只构建、不上传,用于合并前校验。
28
on:
39
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: '要构建并上传的版本标签,例如 v1.0.20260920;留空则跟随当前分支或标签'
13+
required: false
14+
type: string
415
push:
516
tags:
617
- 'v*'
18+
branches:
19+
- main
20+
- master
21+
release:
22+
types: [published, released]
23+
pull_request:
24+
branches: [main, master]
725

826
permissions:
927
contents: write
1028

29+
# 同一标签可能同时被「推标签」和「发布 Release」触发,串行执行避免重复上传
30+
concurrency:
31+
group: 'tauri-release-${{ github.workflow }}-${{ github.ref }}'
32+
cancel-in-progress: false
33+
1134
jobs:
1235
publish-tauri:
13-
name: '构建并发布 ${{ matrix.platform }}'
36+
name: '${{ matrix.label }}'
1437
runs-on: ${{ matrix.platform }}
1538
strategy:
1639
fail-fast: false
1740
matrix:
1841
include:
19-
# macOS:universal 同时打包 x64 + arm64
42+
# Windows x64:NSIS 安装包,双击即装即用(缺失 WebView2 时安装器会自动补齐)
43+
- platform: windows-latest
44+
label: 'Windows x64 · NSIS'
45+
args: '--target x86_64-pc-windows-msvc --bundles nsis'
46+
rust-targets: ''
47+
# macOS:universal dmg 同时含 x64 + arm64,ad-hoc 签名,无需开发者证书
2048
- platform: macos-latest
21-
args: '--target universal-apple-darwin'
22-
rust-targets: aarch64-apple-darwin,x86_64-apple-darwin
23-
# Linux x64
49+
label: 'macOS Universal · dmg(ad-hoc 签名)'
50+
args: '--target universal-apple-darwin --bundles dmg'
51+
rust-targets: 'aarch64-apple-darwin,x86_64-apple-darwin'
52+
# Linux x64:AppImage,内置 GTK/WebKit 运行时
2453
- platform: ubuntu-latest
25-
args: '--target x86_64-unknown-linux-gnu'
54+
label: 'Linux x64 · AppImage'
55+
args: '--target x86_64-unknown-linux-gnu --bundles appimage'
2656
rust-targets: ''
27-
# Linux arm64(GitHub 原生 ARM runner)
57+
# Linux arm64:GitHub 原生 ARM runner,避免 QEMU 全量模拟编译
2858
- platform: ubuntu-24.04-arm
29-
args: '--target aarch64-unknown-linux-gnu'
30-
rust-targets: ''
31-
# Windows x64:只打 NSIS(WiX/MSI 对版本号有 patch<=65535 限制)
32-
- platform: windows-latest
33-
args: '--target x86_64-pc-windows-msvc --bundles nsis'
59+
label: 'Linux arm64 · AppImage'
60+
args: '--target aarch64-unknown-linux-gnu --bundles appimage'
3461
rust-targets: ''
3562
steps:
36-
- uses: actions/checkout@v4
37-
- uses: actions/setup-node@v4
38-
with:
39-
node-version: 22
40-
cache: npm
41-
cache-dependency-path: package-lock.json
42-
- uses: dtolnay/rust-toolchain@stable
43-
with:
44-
targets: ${{ matrix.rust-targets }}
45-
- uses: swatinem/rust-cache@v2
46-
with:
47-
workspaces: './src-tauri -> target'
48-
- name: '安装 Linux 系统依赖'
49-
if: runner.os == 'Linux'
50-
run: |
51-
sudo apt-get update
52-
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf xdg-utils
53-
- name: '安装前端依赖'
54-
run: npm ci --no-audit --no-fund
55-
- name: '构建并发布到 Release'
56-
uses: tauri-apps/tauri-action@v0
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59-
with:
60-
tagName: 'v__VERSION__'
61-
releaseName: 'v__VERSION__'
62-
releaseBody: '自动构建的跨平台桌面应用安装包(Windows / macOS / Linux)'
63-
releaseDraft: false
64-
prerelease: false
65-
args: ${{ matrix.args }}
63+
- name: '检出代码'
64+
uses: actions/checkout@v4
65+
with:
66+
ref: ${{ github.event.inputs.tag || github.event.release.tag_name || github.ref }}
67+
68+
- name: '安装 Node.js'
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: 22
72+
cache: npm
73+
cache-dependency-path: package-lock.json
74+
75+
- name: '校验版本号与发布标签一致'
76+
shell: bash
77+
env:
78+
EVENT_NAME: ${{ github.event_name }}
79+
INPUT_TAG: ${{ github.event.inputs.tag }}
80+
RELEASE_TAG: ${{ github.event.release.tag_name }}
81+
REF_NAME: ${{ github.ref_name }}
82+
run: |
83+
set -euo pipefail
84+
if [ "$EVENT_NAME" = "pull_request" ]; then
85+
echo 'PR 校验:跳过发布标签一致性检查。'
86+
exit 0
87+
fi
88+
version="$(node -p "require('./src-tauri/tauri.conf.json').version")"
89+
tag="${INPUT_TAG:-}"
90+
if [ "$EVENT_NAME" = "workflow_dispatch" ] && [ -z "$tag" ]; then
91+
echo '手动触发且未指定标签:只构建,跳过一致性校验。'
92+
exit 0
93+
fi
94+
[ -n "$tag" ] || tag="${RELEASE_TAG:-$REF_NAME}"
95+
echo "源码版本号: v${version}"
96+
echo "发布标签: ${tag:-<未指定>}"
97+
if [ -z "${tag}" ] || [ "${tag}" = "main" ] || [ "${tag}" = "master" ]; then
98+
echo '未指定发布标签,跳过一致性校验。'
99+
exit 0
100+
fi
101+
if [ "${tag}" != "v${version}" ]; then
102+
echo "::error::发布标签 ${tag} 与源码版本号 v${version} 不一致,请先把版本号改成 ${tag#v} 再发布。"
103+
exit 1
104+
fi
105+
106+
- name: '安装 Rust 工具链'
107+
uses: dtolnay/rust-toolchain@stable
108+
with:
109+
targets: ${{ matrix.rust-targets }}
110+
111+
- name: '缓存 Rust 编译产物'
112+
uses: swatinem/rust-cache@v2
113+
with:
114+
workspaces: './src-tauri -> target'
115+
116+
- name: '安装 Linux 打包依赖'
117+
if: runner.os == 'Linux'
118+
run: |
119+
sudo apt-get update
120+
sudo apt-get install -y \
121+
build-essential file xdg-utils patchelf \
122+
libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev
123+
124+
- name: '安装前端依赖'
125+
run: npm ci --no-audit --no-fund
126+
127+
- name: '构建安装包并上传到 Release'
128+
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
129+
uses: tauri-apps/tauri-action@v0
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
# ad-hoc 签名:不需要 Apple 开发者证书,dmg 可正常分发(首次打开需右键 → 打开)
133+
APPLE_SIGNING_IDENTITY: '-'
134+
with:
135+
tagName: 'v__VERSION__'
136+
releaseName: 'SimpleWebShell Desktop v__VERSION__'
137+
releaseBody: |
138+
## SimpleWebShell Desktop v__VERSION__
139+
140+
### 安装包(随版本自动构建,双击即用)
141+
| 平台 | 安装包 |
142+
| --- | --- |
143+
| Windows x64 | `*-x64-setup.exe`(NSIS 安装向导) |
144+
| macOS Universal(Apple Silicon + Intel) | `*_universal.dmg`(ad-hoc 签名) |
145+
| Linux x64 | `*_amd64.AppImage` |
146+
| Linux arm64 | `*_arm64.AppImage` |
147+
148+
### 使用方式
149+
- Windows:双击 `-setup.exe`,按向导完成安装。
150+
- macOS:打开 dmg,把应用拖入「应用程序」;ad-hoc 签名未做公证,首次启动请右键 → 打开。
151+
- Linux:先执行 `chmod +x *.AppImage`,再双击运行(AppImage 已内置 GTK/WebKit 运行时)。
152+
153+
完整性校验见 `SHA256SUMS.txt`、`checksums-md5.txt`、`checksums-sha1.txt`。
154+
releaseDraft: false
155+
prerelease: false
156+
# 由 Release 事件触发时,直接挂到用户已发布的 Release 上,不改写其标题与说明
157+
releaseId: ${{ github.event.release.id }}
158+
args: ${{ matrix.args }}
159+
retryAttempts: 3
160+
161+
- name: '构建安装包(PR / 分支校验,不上传 Release)'
162+
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' && !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
163+
shell: bash
164+
run: npm run tauri build -- ${{ matrix.args }}
165+
166+
- name: '上传安装包工件(供 SHA256 汇总)'
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: 'tauri-${{ matrix.platform }}'
170+
path: |
171+
src-tauri/target/*/release/bundle/nsis/*-setup.exe
172+
src-tauri/target/*/release/bundle/dmg/*.dmg
173+
src-tauri/target/*/release/bundle/appimage/*.AppImage
174+
if-no-files-found: error
175+
retention-days: 1
176+
177+
checksums:
178+
name: '生成校验文件'
179+
needs: publish-tauri
180+
runs-on: ubuntu-latest
181+
steps:
182+
- name: '汇总各平台安装包工件'
183+
uses: actions/download-artifact@v4
184+
with:
185+
pattern: 'tauri-*'
186+
path: artifacts
187+
merge-multiple: true
188+
- name: '生成 SHA256/MD5/SHA1 校验文件'
189+
run: |
190+
set -euo pipefail
191+
cd artifacts
192+
find . -type f \
193+
! -name 'SHA256SUMS.txt' \
194+
! -name 'checksums-md5.txt' \
195+
! -name 'checksums-sha1.txt' -print0 \
196+
| sort -z | xargs -0 -r sha256sum > SHA256SUMS.txt
197+
find . -type f \
198+
! -name 'SHA256SUMS.txt' \
199+
! -name 'checksums-md5.txt' \
200+
! -name 'checksums-sha1.txt' -print0 \
201+
| sort -z | xargs -0 -r md5sum > checksums-md5.txt
202+
find . -type f \
203+
! -name 'SHA256SUMS.txt' \
204+
! -name 'checksums-md5.txt' \
205+
! -name 'checksums-sha1.txt' -print0 \
206+
| sort -z | xargs -0 -r sha1sum > checksums-sha1.txt
207+
cat SHA256SUMS.txt checksums-md5.txt checksums-sha1.txt
208+
- name: '上传到 Release'
209+
if: github.event_name == 'release' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '')
210+
uses: softprops/action-gh-release@v2
211+
with:
212+
tag_name: ${{ github.event.inputs.tag || github.event.release.tag_name || github.ref_name }}
213+
files: |
214+
artifacts/SHA256SUMS.txt
215+
artifacts/checksums-md5.txt
216+
artifacts/checksums-sha1.txt
217+
fail_on_unmatched_files: true

0 commit comments

Comments
 (0)