Skip to content

Commit e62f270

Browse files
committed
chore: 跨平台构建脚本 + CI/CD 改进 + 行尾规范
- 新增 .gitattributes 统一 LF 行尾,解决 Mac/Windows 协作 CRLF 问题 - 新增 build.ps1 Windows 本地构建脚本(支持 -Debug/-Clean 参数) - 新增 build.sh macOS/Linux 本地构建脚本 - 新增 .windsurf/workflows/release.md 发版操作工作流 - release.yml: 将 Release Notes 更新抽为独立 job,彻底解决多 matrix job 竞争条件 - release.yml: 补充代码签名环境变量注释占位,开源后可直接配 Secrets 启用 - ci.yml: 增加 cargo fmt --check 和 cargo clippy -D warnings 质量门禁 - .gitignore: 补充 Windows 平台特有文件、内部报告、IDE 文件 - docs/index.html: 修正 openclaw 仓库 URL - README.md: 修正 openclaw 仓库 URL
1 parent dab61cc commit e62f270

11 files changed

Lines changed: 506 additions & 73 deletions

File tree

.gitattributes

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 统一使用 LF 行尾(适配 macOS / Linux / Windows 跨平台协作)
2+
* text=auto eol=lf
3+
4+
# Windows 批处理脚本保持 CRLF
5+
*.bat text eol=crlf
6+
*.cmd text eol=crlf
7+
8+
# 二进制文件不处理行尾
9+
*.png binary
10+
*.jpg binary
11+
*.jpeg binary
12+
*.gif binary
13+
*.ico binary
14+
*.icns binary
15+
*.woff binary
16+
*.woff2 binary
17+
*.ttf binary
18+
*.otf binary
19+
*.zip binary
20+
*.exe binary
21+
*.dll binary
22+
*.dylib binary
23+
*.so binary
24+
25+
# Rust 锁文件
26+
Cargo.lock text eol=lf

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,21 @@ jobs:
7070
libgtk-3-dev \
7171
libayatana-appindicator3-dev
7272
73+
# Rust 格式检查
74+
- name: Rust 格式检查
75+
working-directory: src-tauri
76+
run: cargo fmt --all -- --check
77+
7378
# Rust 编译检查
7479
- name: Rust 编译检查
7580
working-directory: src-tauri
7681
run: cargo check
7782

83+
# Rust Lint(警告视为错误)
84+
- name: Rust Clippy
85+
working-directory: src-tauri
86+
run: cargo clippy --all-targets -- -D warnings
87+
7888
# 前端构建验证
7989
- name: 前端构建验证
8090
run: npm run build

.github/workflows/release.yml

Lines changed: 92 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ on:
1515
default: 'v1.0.0'
1616

1717
jobs:
18-
release:
18+
# ── 跨平台构建 job ─────────────────────────────────────────────────────────
19+
build:
1920
name: 构建 (${{ matrix.platform.name }})
2021
runs-on: ${{ matrix.platform.os }}
2122
permissions:
@@ -24,58 +25,59 @@ jobs:
2425
fail-fast: false
2526
matrix:
2627
platform:
27-
# macOS Apple Silicon (ARM64)
28-
- name: macOS (ARM64)
28+
- name: macOS (Apple Silicon)
2929
os: macos-latest
3030
args: --target aarch64-apple-darwin
3131
rust_target: aarch64-apple-darwin
32-
# macOS Intel (x64)
3332
- name: macOS (Intel)
3433
os: macos-latest
3534
args: --target x86_64-apple-darwin
3635
rust_target: x86_64-apple-darwin
37-
# Linux x86_64
3836
- name: Linux (x64)
3937
os: ubuntu-latest
4038
args: ""
4139
rust_target: ""
42-
# Windows x86_64
4340
- name: Windows (x64)
4441
os: windows-latest
4542
args: ""
4643
rust_target: ""
4744

4845
steps:
49-
# 签出代码
5046
- name: 签出代码
5147
uses: actions/checkout@v4
5248
with:
5349
fetch-depth: 0
5450

55-
# 安装 Node.js 22
51+
- name: 设置版本标签
52+
id: vars
53+
shell: bash
54+
run: |
55+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
56+
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> "$GITHUB_ENV"
57+
else
58+
echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV"
59+
fi
60+
5661
- name: 安装 Node.js
5762
uses: actions/setup-node@v4
5863
with:
5964
node-version: 22
6065
cache: npm
6166

62-
# 安装前端依赖
6367
- name: 安装前端依赖
6468
run: npm ci
6569

66-
# 安装 Rust 工具链 (stable)
6770
- name: 安装 Rust 工具链
6871
uses: dtolnay/rust-toolchain@stable
6972
with:
7073
targets: ${{ matrix.platform.rust_target }}
7174

72-
# Rust 编译缓存
7375
- name: Rust 编译缓存
7476
uses: swatinem/rust-cache@v2
7577
with:
7678
workspaces: src-tauri -> target
79+
key: ${{ matrix.platform.name }}
7780

78-
# Linux 专用: 安装 Tauri v2 系统依赖
7981
- name: 安装 Linux 系统依赖
8082
if: runner.os == 'Linux'
8183
run: |
@@ -88,61 +90,108 @@ jobs:
8890
libgtk-3-dev \
8991
libayatana-appindicator3-dev
9092
91-
- name: 设置 Release 标签
92-
id: vars
93+
- name: 构建 Tauri 应用
94+
uses: tauri-apps/tauri-action@v0
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
# macOS 代码签名(可选)
98+
# APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
99+
# APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
100+
# APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
101+
# APPLE_ID: ${{ secrets.APPLE_ID }}
102+
# APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
103+
# APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
104+
# Windows 代码签名(可选)
105+
# TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
106+
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
107+
with:
108+
tagName: ${{ env.TAG_NAME }}
109+
releaseName: "ClawPanel ${{ env.TAG_NAME }}"
110+
releaseBody: "正在构建所有平台安装包,请稍候..."
111+
releaseDraft: false
112+
prerelease: false
113+
args: ${{ matrix.platform.args }}
114+
115+
# ── 所有平台构建完成后,统一更新 Release Notes ─────────────────────────────
116+
# 独立 job 确保只执行一次,彻底避免多个 matrix job 的竞争条件
117+
update-release-notes:
118+
name: 更新 Release Notes
119+
needs: build
120+
runs-on: ubuntu-latest
121+
if: always() && needs.build.result != 'cancelled'
122+
permissions:
123+
contents: write
124+
125+
steps:
126+
- name: 签出代码
127+
uses: actions/checkout@v4
128+
with:
129+
fetch-depth: 0
130+
131+
- name: 设置版本标签
93132
shell: bash
94133
run: |
95134
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
96-
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
135+
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> "$GITHUB_ENV"
97136
else
98-
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
137+
echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV"
99138
fi
100139
101-
# 生成 Release Body(下载引导 + 动态 changelog)
102-
- name: 生成 Release Body
103-
id: release_body
140+
- name: 生成并更新 Release Notes
104141
shell: bash
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
BUILD_RESULT: ${{ needs.build.result }}
105145
run: |
106146
VERSION="${TAG_NAME#v}"
107147
108-
# 获取上一个 tag,用于生成 changelog
109148
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v' | sed -n '2p' || echo "")
110-
111-
# 动态生成 changelog
112149
if [ -n "$PREV_TAG" ]; then
113-
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | head -30)
114-
CHANGELOG_HEADER="自 ${PREV_TAG} 以来的更新"
150+
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | head -30 || echo "")
151+
CHANGELOG_HEADER="自 ${PREV_TAG} 以来的变更"
152+
else
153+
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges -20 || echo "")
154+
CHANGELOG_HEADER="主要变更"
155+
fi
156+
157+
# 构建状态标记
158+
if [ "$BUILD_RESULT" = "success" ]; then
159+
STATUS_BADGE="✅ 全部平台构建成功"
115160
else
116-
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges -20)
117-
CHANGELOG_HEADER="主要更新"
161+
STATUS_BADGE="⚠️ 部分平台构建失败,请查看 [Actions 日志](https://github.com/${{ github.repository }}/actions)"
118162
fi
119163
120-
# 写入 Release Body
164+
cat > release_body.md << 'ENDOFBODY'
165+
PLACEHOLDER
166+
ENDOFBODY
167+
121168
cat > release_body.md << ENDOFBODY
169+
${STATUS_BADGE}
170+
122171
## 下载安装
123172
124173
根据你的操作系统选择对应安装包:
125174
126175
### macOS
127-
| 芯片 | 安装包 | 说明 |
128-
|------|--------|------|
129-
| Apple Silicon (M1/M2/M3/M4) | \`ClawPanel_${VERSION}_aarch64.dmg\` | 2020 年末及之后的 Mac |
130-
| Intel | \`ClawPanel_${VERSION}_x64.dmg\` | 2020 年及之前的 Mac |
176+
| 芯片 | 安装包 |
177+
|------|--------|
178+
| Apple Silicon (M1/M2/M3/M4) | \`ClawPanel_${VERSION}_aarch64.dmg\` |
179+
| Intel | \`ClawPanel_${VERSION}_x64.dmg\` |
131180
132-
> 不确定芯片类型?点击左上角 → 关于本机,查看「芯片」一栏
181+
> 首次打开提示"无法验证开发者":前往**系统设置 → 隐私与安全性**,点击「仍要打开」
133182
134183
### Windows
135-
| 格式 | 安装包 | 说明 |
136-
|------|--------|------|
137-
| EXE 安装器 | \`ClawPanel_${VERSION}_x64-setup.exe\` | 推荐,双击安装 |
138-
| MSI 安装器 | \`ClawPanel_${VERSION}_x64_en-US.msi\` | 企业部署 / 静默安装 |
184+
| 格式 | 安装包 |
185+
|------|--------|
186+
| EXE 安装器(推荐) | \`ClawPanel_${VERSION}_x64-setup.exe\` |
187+
| MSI 安装器 | \`ClawPanel_${VERSION}_x64_en-US.msi\` |
139188
140189
### Linux
141-
| 格式 | 安装包 | 说明 |
142-
|------|--------|------|
143-
| AppImage | \`ClawPanel_${VERSION}_amd64.AppImage\` | 免安装,\`chmod +x\` 后直接运行 |
144-
| DEB | \`ClawPanel_${VERSION}_amd64.deb\` | Debian / Ubuntu:\`sudo dpkg -i *.deb\` |
145-
| RPM | \`ClawPanel-${VERSION}-1.x86_64.rpm\` | Fedora / RHEL:\`sudo rpm -i *.rpm\` |
190+
| 格式 | 安装包 |
191+
|------|--------|
192+
| AppImage(免安装) | \`ClawPanel_${VERSION}_amd64.AppImage\` |
193+
| DEB(Debian/Ubuntu) | \`ClawPanel_${VERSION}_amd64.deb\` |
194+
| RPM(Fedora/RHEL) | \`ClawPanel-${VERSION}-1.x86_64.rpm\` |
146195
147196
---
148197
@@ -152,34 +201,7 @@ jobs:
152201
153202
---
154203
155-
完整更新日志请查看 [CHANGELOG.md](https://github.com/qingchencloud/clawpanel/blob/main/CHANGELOG.md)
204+
完整日志见 [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md)
156205
ENDOFBODY
157206
158-
# 去除 heredoc 缩进
159-
sed -i.bak 's/^ //' release_body.md && rm -f release_body.md.bak
160-
161-
# 使用 tauri-action 构建并发布
162-
- name: 构建 Tauri 应用
163-
uses: tauri-apps/tauri-action@v0
164-
env:
165-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166-
with:
167-
tagName: ${{ env.TAG_NAME }}
168-
releaseName: "ClawPanel ${{ env.TAG_NAME }}"
169-
releaseBody: "构建中,稍后更新..."
170-
releaseDraft: false
171-
prerelease: false
172-
args: ${{ matrix.platform.args }}
173-
174-
# 更新 Release Body(仅第一个完成的 job 执行)
175-
- name: 更新 Release 描述
176-
if: always()
177-
shell: bash
178-
env:
179-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
180-
run: |
181-
# 检查当前 Release body 是否为空或默认值,避免重复更新
182-
CURRENT_BODY=$(gh release view "$TAG_NAME" --json body -q '.body' 2>/dev/null || echo "")
183-
if [ ${#CURRENT_BODY} -lt 100 ]; then
184-
gh release edit "$TAG_NAME" --notes-file release_body.md
185-
fi
207+
gh release edit "$TAG_NAME" --notes-file release_body.md

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
1+
# 依赖
12
node_modules/
3+
4+
# 构建产物
25
dist/
36
src-tauri/target/
7+
8+
# 日志
49
*.log
10+
tauri-dev.log
11+
api_doc_mcp.log
12+
13+
# macOS
514
.DS_Store
15+
.AppleDouble
16+
.LSOverride
17+
18+
# Windows
19+
Thumbs.db
20+
ehthumbs.db
21+
Desktop.ini
22+
$RECYCLE.BIN/
23+
*.lnk
24+
25+
# 构建临时文件
26+
nul
27+
release_body.md
28+
release_body.md.bak
29+
30+
# 内部开发文档(不入公开仓)
31+
BLOCKING_ISSUES_REPORT.md
32+
33+
# IDE / 编辑器
34+
.idea/
35+
*.iml
36+
.vscode/settings.json
37+
.vscode/launch.json
38+
*.suo
39+
*.user
40+
*.userosscache
41+
*.sln.docstates
42+
43+
# Rust 开发工具
44+
src-tauri/.cargo/

0 commit comments

Comments
 (0)