Ver Fonte

工作流

黄中银 há 2 semanas atrás
pai
commit
a67e53e4f5
2 ficheiros alterados com 128 adições e 4 exclusões
  1. 123 0
      .github/workflows/RELEASE-WORKFLOW.md
  2. 5 4
      src-tauri/src/commands/install.rs

+ 123 - 0
.github/workflows/RELEASE-WORKFLOW.md

@@ -0,0 +1,123 @@
+# Release 工作流文档
+
+## 概述
+
+该工作流用于自动化构建和发布 Claude AI Installer 应用程序,支持 Windows、macOS 和 Linux 三个平台。
+
+## 触发条件
+
+```yaml
+on:
+  push:
+    tags:
+      - 'v*'
+```
+
+当推送以 `v` 开头的 tag 时触发(如 `v1.0.0`、`v2.1.3`)。
+
+---
+
+## 工作流程图
+
+```
+┌─────────────────────┐
+│   推送 v* 标签       │
+└──────────┬──────────┘
+           ▼
+┌─────────────────────────────────────────────────────┐
+│              Job 1: build (并行执行)                  │
+├─────────────┬─────────────┬─────────────┬───────────┤
+│  Windows    │  macOS ARM  │ macOS Intel │  Linux    │
+│  x64        │  (M1/M2/M3) │    x64      │   x64     │
+└─────────────┴─────────────┴─────────────┴───────────┘
+           │
+           ▼
+┌─────────────────────┐
+│  Job 2: release     │
+│  - 下载所有构建产物  │
+│  - 创建 GitHub Release │
+│  - 上传安装包        │
+└─────────────────────┘
+```
+
+---
+
+## Job 详细说明
+
+### Job 1: build
+
+**构建矩阵**:
+
+| 平台 | 运行环境 | Target |
+|------|----------|--------|
+| Windows | `windows-latest` | `x86_64-pc-windows-msvc` |
+| macOS ARM | `macos-latest` | `aarch64-apple-darwin` |
+| macOS Intel | `macos-latest` | `x86_64-apple-darwin` |
+| Linux | `ubuntu-22.04` | `x86_64-unknown-linux-gnu` |
+
+**步骤**:
+
+| 步骤 | 说明 |
+|------|------|
+| Checkout code | 检出 main 分支最新代码 |
+| Setup Node.js | 配置 Node.js 20 |
+| Install Rust | 安装 Rust 工具链及对应 target |
+| Cache Cargo | 缓存 Cargo 依赖加速构建 |
+| Install Linux deps | (仅 Linux) 安装 GTK、WebKit 等系统依赖 |
+| Install dependencies | 安装 npm 依赖 |
+| Build application | 执行构建脚本 `node scripts/build.js` |
+| Upload artifacts | 上传构建产物到 `artifacts-{platform}` |
+
+**环境变量**:
+- `TAURI_SIGNING_PRIVATE_KEY` - Tauri 签名私钥(来自 Secrets)
+
+---
+
+### Job 2: release
+
+**依赖**: `build`
+
+**运行环境**: `ubuntu-latest`
+
+**权限**: `contents: write`
+
+| 步骤 | 说明 |
+|------|------|
+| Download artifacts | 下载所有平台的构建产物并合并 |
+| List artifacts | 列出产物文件(调试用) |
+| Create Release | 创建 GitHub Release 并上传文件 |
+
+---
+
+## 发布产物
+
+| 平台 | 文件 | 说明 |
+|------|------|------|
+| **Windows** | `*-win-x64-setup.exe` | NSIS 安装程序(推荐) |
+| | `*-win-x64-portable.exe` | 便携版 |
+| | `*-win-x64.msi` | MSI 安装程序 |
+| **macOS** | `*-mac-arm64.dmg` | Apple Silicon |
+| | `*-mac-x64.dmg` | Intel |
+| **Linux** | `*-linux-x64.deb` | Debian/Ubuntu |
+| | `*-linux-x64.AppImage` | 通用 AppImage |
+
+---
+
+## 所需 Secrets
+
+| 名称 | 用途 |
+|------|------|
+| `TAURI_SIGNING_PRIVATE_KEY` | Tauri 应用签名私钥 |
+| `GITHUB_TOKEN` | GitHub Release 创建(自动提供) |
+
+---
+
+## 使用方法
+
+```bash
+# 创建并推送版本标签
+git tag v1.0.0
+git push origin v1.0.0
+```
+
+工作流将自动执行构建并创建 Release。

+ 5 - 4
src-tauri/src/commands/install.rs

@@ -1,6 +1,7 @@
+use crate::commands::config::{get_git_mirror_config, get_nodejs_mirror_config};
 use crate::commands::AppState;
 use crate::commands::AppState;
-use crate::utils::http::get_client;
-use crate::utils::shell::run_shell_hidden;
+use crate::utils::http::{get_client, HttpRequest};
+use crate::utils::shell::{run_program, run_shell_hidden, CommandOptions};
 use futures::StreamExt;
 use futures::StreamExt;
 use serde::{Deserialize, Serialize};
 use serde::{Deserialize, Serialize};
 use std::io::Write;
 use std::io::Write;
@@ -566,7 +567,7 @@ where
 async fn install_vscode<F, C>(
 async fn install_vscode<F, C>(
     _app: &tauri::AppHandle,
     _app: &tauri::AppHandle,
     _state: &State<'_, AppState>,
     _state: &State<'_, AppState>,
-    _options: &InstallOptions,
+    options: &InstallOptions,
     emit_status: F,
     emit_status: F,
     is_cancelled: C,
     is_cancelled: C,
 ) -> Result<InstallResult, String>
 ) -> Result<InstallResult, String>
@@ -752,7 +753,7 @@ where
 async fn install_git<F, C>(
 async fn install_git<F, C>(
     _app: &tauri::AppHandle,
     _app: &tauri::AppHandle,
     _state: &State<'_, AppState>,
     _state: &State<'_, AppState>,
-    _options: &InstallOptions,
+    options: &InstallOptions,
     emit_status: F,
     emit_status: F,
     is_cancelled: C,
     is_cancelled: C,
 ) -> Result<InstallResult, String>
 ) -> Result<InstallResult, String>