name: 桌面客户端发布 # 触发方式: 手动 (workflow_dispatch)。 # 在 GitHub Actions 页面点 "Run workflow", 选择要构建的平台 + 版本号, # 构建完成后自动创建/更新 Release 并上传安装包。 # # 为什么不用 tag 自动触发: # - 多平台并行构建, mac/linux 未就绪时会自动失败污染 Release # - 手动触发可精确控制 "今天只发 Windows, 明天补 mac" # - 版本号通过 input 传入, 与 tag 解耦, 更灵活 # # 使用: # gh workflow run release.yml -f version=v0.2.0 -f platforms=windows # 或 GitHub 网页 Actions → 桌面客户端发布 → Run workflow on: workflow_dispatch: inputs: version: description: '版本号 (如 v0.1.33, 用作 Release tag 和标题)' required: true default: 'v0.1.33' platforms: description: '要构建的平台 (逗号分隔: windows,macos,linux)' required: true default: 'windows' prerelease: description: '是否为预发布 (勾选则标记为 Pre-release)' type: boolean default: false permissions: contents: write # 创建 Release 需要写权限 jobs: # 第一步: 过滤出本次要构建的平台 prepare: runs-on: ubuntu-latest outputs: matrix: ${{ steps.filter.outputs.matrix }} steps: - id: filter run: | REQUESTED="${{ github.event.inputs.platforms }}" ALL='[{"os":"windows-latest","artifact":"TickFlowStockPanel-win-x64.zip","platform":"windows"},{"os":"macos-latest","artifact":"TickFlowStockPanel-macos.zip","platform":"macos"},{"os":"ubuntu-latest","artifact":"TickFlowStockPanel-linux-x64.tar.gz","platform":"linux"}]' # 按 input 过滤平台 python3 -c " import json, sys requested = '${{ github.event.inputs.platforms }}'.split(',') requested = [r.strip() for r in requested if r.strip()] all_platforms = json.loads('''$ALL''') selected = [p for p in all_platforms if p['platform'] in requested] print('matrix=' + json.dumps({'include': selected})) with open('$GITHUB_OUTPUT', 'a') as f: f.write('matrix=' + json.dumps({'include': selected}) + '\n') " # 第二步: 各平台并行构建 build: needs: prepare runs-on: ${{ matrix.os }} strategy: fail-fast: false # 单平台失败不影响其他平台 matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} steps: - name: 检出代码 uses: actions/checkout@v4 - name: 安装 pnpm uses: pnpm/action-setup@v4 with: version: 9 - name: 设置 Node 20 uses: actions/setup-node@v4 with: node-version: '20' cache: 'pnpm' cache-dependency-path: frontend/pnpm-lock.yaml - name: 构建前端 working-directory: frontend run: | pnpm install --frozen-lockfile pnpm build - name: 安装 uv uses: astral-sh/setup-uv@v3 with: enable-cache: true - name: 设置 Python run: uv python install 3.12 - name: 安装后端依赖 (含 desktop, 不含 backtest) working-directory: backend # --no-dev 排除 pytest/ruff/mypy; --extra desktop 装 pywebview # 不加 --extra backtest, 主包不含 vectorbt/numba/llvmlite run: uv sync --no-dev --extra desktop - name: 安装 PyInstaller run: uv pip install pyinstaller - name: 打包 (PyInstaller) run: uv run pyinstaller packaging/tickflow.spec --noconfirm - name: 压缩产物 (Windows) if: matrix.platform == 'windows' run: | cd dist 7z a -tzip ../${{ matrix.artifact }} TickFlowStockPanel shell: bash - name: 压缩产物 (macOS) if: matrix.platform == 'macos' run: | cd dist zip -r -q ../${{ matrix.artifact }} TickFlowStockPanel - name: 压缩产物 (Linux) if: matrix.platform == 'linux' run: | cd dist tar -czf ../${{ matrix.artifact }} TickFlowStockPanel - name: 上传产物为构建产物 (备查) uses: actions/upload-artifact@v4 with: name: ${{ matrix.artifact }} path: ${{ matrix.artifact }} - name: 上传到 GitHub Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.event.inputs.version }} name: ${{ github.event.inputs.version }} files: ${{ matrix.artifact }} prerelease: ${{ github.event.inputs.prerelease }} generate_release_notes: true # 自动从 commit 生成 changelog body: | ## 桌面客户端 ${{ github.event.inputs.version }} ### 下载 选择对应平台的安装包, 解压后双击运行: | 平台 | 文件 | | :--- | :--- | | **Windows** | `TickFlowStockPanel-win-x64.zip` → 解压运行 `TickFlowStockPanel.exe` | | **macOS** | `TickFlowStockPanel-macos.zip` → 解压后右键打开 (绕过 Gatekeeper) | | **Linux** | `TickFlowStockPanel-linux-x64.tar.gz` → 解压运行 | ### 说明 - 数据存储在用户目录 (Windows `%LOCALAPPDATA%`、mac `~/Library`、Linux `~/.local/share`), 卸载重装不丢数据 - 含纯 Polars 回测引擎; 不含 vectorbt 回测 (为控制体积) - 系统通知: 设置 → 实时监控 → 系统通知 - 检查更新: 设置 → 系统设置 → 关于