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
This commit is contained in:
晴天
2026-03-04 12:17:48 +08:00
parent dab61ccd24
commit e62f270422
11 changed files with 506 additions and 73 deletions

View File

@@ -70,11 +70,21 @@ jobs:
libgtk-3-dev \
libayatana-appindicator3-dev
# Rust 格式检查
- name: Rust 格式检查
working-directory: src-tauri
run: cargo fmt --all -- --check
# Rust 编译检查
- name: Rust 编译检查
working-directory: src-tauri
run: cargo check
# Rust Lint警告视为错误
- name: Rust Clippy
working-directory: src-tauri
run: cargo clippy --all-targets -- -D warnings
# 前端构建验证
- name: 前端构建验证
run: npm run build

View File

@@ -15,7 +15,8 @@ on:
default: 'v1.0.0'
jobs:
release:
# ── 跨平台构建 job ─────────────────────────────────────────────────────────
build:
name: 构建 (${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
permissions:
@@ -24,58 +25,59 @@ jobs:
fail-fast: false
matrix:
platform:
# macOS Apple Silicon (ARM64)
- name: macOS (ARM64)
- name: macOS (Apple Silicon)
os: macos-latest
args: --target aarch64-apple-darwin
rust_target: aarch64-apple-darwin
# macOS Intel (x64)
- name: macOS (Intel)
os: macos-latest
args: --target x86_64-apple-darwin
rust_target: x86_64-apple-darwin
# Linux x86_64
- name: Linux (x64)
os: ubuntu-latest
args: ""
rust_target: ""
# Windows x86_64
- name: Windows (x64)
os: windows-latest
args: ""
rust_target: ""
steps:
# 签出代码
- name: 签出代码
uses: actions/checkout@v4
with:
fetch-depth: 0
# 安装 Node.js 22
- name: 设置版本标签
id: vars
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> "$GITHUB_ENV"
else
echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV"
fi
- name: 安装 Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# 安装前端依赖
- name: 安装前端依赖
run: npm ci
# 安装 Rust 工具链 (stable)
- name: 安装 Rust 工具链
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.rust_target }}
# Rust 编译缓存
- name: Rust 编译缓存
uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
key: ${{ matrix.platform.name }}
# Linux 专用: 安装 Tauri v2 系统依赖
- name: 安装 Linux 系统依赖
if: runner.os == 'Linux'
run: |
@@ -88,61 +90,108 @@ jobs:
libgtk-3-dev \
libayatana-appindicator3-dev
- name: 设置 Release 标签
id: vars
- name: 构建 Tauri 应用
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# macOS 代码签名(可选)
# APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
# APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
# APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
# APPLE_ID: ${{ secrets.APPLE_ID }}
# APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
# APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
# Windows 代码签名(可选)
# TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
# TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
tagName: ${{ env.TAG_NAME }}
releaseName: "ClawPanel ${{ env.TAG_NAME }}"
releaseBody: "正在构建所有平台安装包,请稍候..."
releaseDraft: false
prerelease: false
args: ${{ matrix.platform.args }}
# ── 所有平台构建完成后,统一更新 Release Notes ─────────────────────────────
# 独立 job 确保只执行一次,彻底避免多个 matrix job 的竞争条件
update-release-notes:
name: 更新 Release Notes
needs: build
runs-on: ubuntu-latest
if: always() && needs.build.result != 'cancelled'
permissions:
contents: write
steps:
- name: 签出代码
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 设置版本标签
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> "$GITHUB_ENV"
else
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
echo "TAG_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV"
fi
# 生成 Release Body下载引导 + 动态 changelog
- name: 生成 Release Body
id: release_body
- name: 生成并更新 Release Notes
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_RESULT: ${{ needs.build.result }}
run: |
VERSION="${TAG_NAME#v}"
# 获取上一个 tag用于生成 changelog
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v' | sed -n '2p' || echo "")
# 动态生成 changelog
if [ -n "$PREV_TAG" ]; then
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | head -30)
CHANGELOG_HEADER="自 ${PREV_TAG} 以来的更"
CHANGELOG=$(git log "${PREV_TAG}..HEAD" --pretty=format:"- %s" --no-merges | head -30 || echo "")
CHANGELOG_HEADER="自 ${PREV_TAG} 以来的更"
else
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges -20)
CHANGELOG_HEADER="主要更"
CHANGELOG=$(git log --pretty=format:"- %s" --no-merges -20 || echo "")
CHANGELOG_HEADER="主要更"
fi
# 写入 Release Body
# 构建状态标记
if [ "$BUILD_RESULT" = "success" ]; then
STATUS_BADGE="✅ 全部平台构建成功"
else
STATUS_BADGE="⚠️ 部分平台构建失败,请查看 [Actions 日志](https://github.com/${{ github.repository }}/actions)"
fi
cat > release_body.md << 'ENDOFBODY'
PLACEHOLDER
ENDOFBODY
cat > release_body.md << ENDOFBODY
${STATUS_BADGE}
## 下载安装
根据你的操作系统选择对应安装包:
### macOS
| 芯片 | 安装包 | 说明 |
|------|--------|------|
| Apple Silicon (M1/M2/M3/M4) | \`ClawPanel_${VERSION}_aarch64.dmg\` | 2020 年末及之后的 Mac |
| Intel | \`ClawPanel_${VERSION}_x64.dmg\` | 2020 年及之前的 Mac |
| 芯片 | 安装包 |
|------|--------|
| Apple Silicon (M1/M2/M3/M4) | \`ClawPanel_${VERSION}_aarch64.dmg\` |
| Intel | \`ClawPanel_${VERSION}_x64.dmg\` |
> 不确定芯片类型?点击左上角 → 关于本机,查看「芯片」一栏
> 首次打开提示"无法验证开发者":前往**系统设置 → 隐私与安全性**,点击「仍要打开」
### Windows
| 格式 | 安装包 | 说明 |
|------|--------|------|
| EXE 安装器 | \`ClawPanel_${VERSION}_x64-setup.exe\` | 推荐,双击安装 |
| MSI 安装器 | \`ClawPanel_${VERSION}_x64_en-US.msi\` | 企业部署 / 静默安装 |
| 格式 | 安装包 |
|------|--------|
| EXE 安装器(推荐) | \`ClawPanel_${VERSION}_x64-setup.exe\` |
| MSI 安装器 | \`ClawPanel_${VERSION}_x64_en-US.msi\` |
### Linux
| 格式 | 安装包 | 说明 |
|------|--------|------|
| AppImage | \`ClawPanel_${VERSION}_amd64.AppImage\` | 免安装,\`chmod +x\` 后直接运行 |
| DEB | \`ClawPanel_${VERSION}_amd64.deb\` | Debian / Ubuntu\`sudo dpkg -i *.deb\` |
| RPM | \`ClawPanel-${VERSION}-1.x86_64.rpm\` | Fedora / RHEL\`sudo rpm -i *.rpm\` |
| 格式 | 安装包 |
|------|--------|
| AppImage(免安装) | \`ClawPanel_${VERSION}_amd64.AppImage\` |
| DEBDebian/Ubuntu | \`ClawPanel_${VERSION}_amd64.deb\` |
| RPMFedora/RHEL | \`ClawPanel-${VERSION}-1.x86_64.rpm\` |
---
@@ -152,34 +201,7 @@ jobs:
---
完整更新日志请查看 [CHANGELOG.md](https://github.com/qingchencloud/clawpanel/blob/main/CHANGELOG.md)
完整日志见 [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md)
ENDOFBODY
# 去除 heredoc 缩进
sed -i.bak 's/^ //' release_body.md && rm -f release_body.md.bak
# 使用 tauri-action 构建并发布
- name: 构建 Tauri 应用
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: ${{ env.TAG_NAME }}
releaseName: "ClawPanel ${{ env.TAG_NAME }}"
releaseBody: "构建中,稍后更新..."
releaseDraft: false
prerelease: false
args: ${{ matrix.platform.args }}
# 更新 Release Body仅第一个完成的 job 执行)
- name: 更新 Release 描述
if: always()
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 检查当前 Release body 是否为空或默认值,避免重复更新
CURRENT_BODY=$(gh release view "$TAG_NAME" --json body -q '.body' 2>/dev/null || echo "")
if [ ${#CURRENT_BODY} -lt 100 ]; then
gh release edit "$TAG_NAME" --notes-file release_body.md
fi
gh release edit "$TAG_NAME" --notes-file release_body.md