瀏覽代碼

用于发布的工作流

黄中银 2 周之前
父節點
當前提交
0c5d017909
共有 2 個文件被更改,包括 148 次插入0 次删除
  1. 118 0
      .github/workflows/release.yml
  2. 30 0
      README.md

+ 118 - 0
.github/workflows/release.yml

@@ -0,0 +1,118 @@
+name: Release
+
+on:
+  push:
+    tags:
+      - 'v*'
+
+jobs:
+  release:
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - os: windows-latest
+            platform: win
+          - os: macos-latest
+            platform: mac
+          - os: ubuntu-latest
+            platform: linux
+
+    runs-on: ${{ matrix.os }}
+
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '20'
+          cache: 'npm'
+
+      - name: Extract version from tag
+        id: version
+        shell: bash
+        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
+
+      - name: Update package.json version
+        shell: bash
+        run: |
+          npm pkg set version=${{ steps.version.outputs.VERSION }}
+
+      - name: Install dependencies
+        run: npm ci
+
+      - name: Type check
+        run: npm run typecheck
+
+      - name: Build frontend
+        run: npx vite build
+
+      - name: Package application
+        run: npx electron-builder --${{ matrix.platform }}
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Build portable version with launcher (Windows only)
+        if: matrix.platform == 'win'
+        shell: pwsh
+        run: |
+          # Build launcher
+          npx pkg launcher/launcher.js --target node18-win-x64 --output release/launcher.exe
+
+          # Find portable exe
+          $portableExe = Get-ChildItem -Path release -Filter "*portable*.exe" | Select-Object -First 1
+          if (-not $portableExe) {
+            Write-Error "Portable exe not found"
+            exit 1
+          }
+
+          $version = "${{ steps.version.outputs.VERSION }}"
+          $portableDirName = "Claude-AI-Installer-$version-portable"
+          $portableDir = "release/$portableDirName"
+
+          # Create directory structure
+          New-Item -ItemType Directory -Force -Path "$portableDir/app"
+          New-Item -ItemType Directory -Force -Path "$portableDir/update"
+
+          # Copy files
+          Copy-Item "release/launcher.exe" "$portableDir/Claude-AI-Installer.exe"
+          Copy-Item $portableExe.FullName "$portableDir/app/Claude-AI-Installer-$version.exe"
+
+          # Create README
+          @"
+          Claude AI Installer - Portable 版本
+
+          使用方法:
+          1. 双击 Claude-AI-Installer.exe 启动程序
+          2. 程序会自动检查更新
+          3. 更新下载后,重启程序即可完成更新
+
+          目录说明:
+          - Claude-AI-Installer.exe: 启动器
+          - app/: 主程序目录
+          - update/: 更新文件临时目录
+
+          版本: $version
+          "@ | Out-File -FilePath "$portableDir/README.txt" -Encoding UTF8
+
+          # Create ZIP
+          Compress-Archive -Path "$portableDir/*" -DestinationPath "release/$portableDirName.zip" -Force
+
+      - name: Upload release assets
+        uses: softprops/action-gh-release@v2
+        with:
+          files: |
+            release/*.exe
+            release/*.dmg
+            release/*.zip
+            release/*.AppImage
+            release/*.deb
+            release/*.rpm
+            release/*.yml
+            release/*.yaml
+          draft: false
+          prerelease: false
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 30 - 0
README.md

@@ -1,5 +1,7 @@
 # Claude AI Installer
 
+[![Release](https://github.com/anthropics/claude-ai-installer/actions/workflows/release.yml/badge.svg)](https://github.com/anthropics/claude-ai-installer/actions/workflows/release.yml)
+
 一个基于 Electron + Vue 3 的桌面应用,帮助用户一键安装 Claude Code 及相关开发工具。
 
 A desktop application built with Electron + Vue 3 to help users install Claude Code and related development tools with one click.
@@ -150,6 +152,8 @@ npm run lint
 
 ## 发布 / Release
 
+### 本地发布 / Local Release
+
 ```bash
 # 补丁版本
 npm run release:patch
@@ -161,6 +165,32 @@ npm run release:minor
 npm run release:major
 ```
 
+### GitHub Actions 自动发布 / GitHub Actions Auto Release
+
+项目配置了 GitHub Actions 工作流,支持自动构建和发布:
+
+**构建工作流 (build.yml)**
+- 触发条件:推送到 `main`/`develop` 分支或创建 PR
+- 自动在 Windows、macOS、Linux 三个平台并行构建
+- 运行测试和类型检查
+- 上传构建产物为 Artifacts
+
+**发布工作流 (release.yml)**
+- 触发条件:推送以 `v` 开头的标签(如 `v1.0.0`)
+- 自动构建所有平台的安装包
+- 自动创建 GitHub Release 并上传安装包
+
+**发布步骤:**
+```bash
+# 1. 更新版本号并创建标签
+npm run release:patch  # 或 release:minor / release:major
+
+# 2. 推送标签到 GitHub
+git push origin --tags
+
+# 3. GitHub Actions 自动构建并发布
+```
+
 ## 构建产物 / Build Outputs
 
 | 平台 | 格式 |