Files
tick-stock-panel/.github/workflows/release.yml
T
shy3130 5721f1fe93 feat: Windows 打包改为 Inno Setup 安装包 (Setup.exe)
- 新增 packaging/tickflow.iss: Inno Setup 脚本
  · 用户目录安装 (不弹 UAC), 桌面+开始菜单快捷方式
  · 卸载时询问是否删除用户数据
  · 内置简中语言包 (ChineseSimplified.isl, 官方仓库获取)
- 新增 packaging/generate_icon.py + icon.ico: 应用图标
  · 与 favicon.svg/Logo.tsx 一致 (紫色方括号 + K线)
  · 用 Pillow 绘制, 多尺寸 (16/32/48/64/128/256)
- spec 加 icon: exe 图标 = 安装包图标 = 快捷方式图标
- release.yml: Windows 步骤改为 choco install innosetup + ISCC 编译
- 本地验证通过: 安装→快捷方式→启动→health 0.1.35 全 OK
2026-06-23 22:26:31 +08:00

165 lines
6.1 KiB
YAML

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-Setup-x64.exe","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: 安装 Inno Setup (仅 Windows)
if: matrix.platform == 'windows'
# Inno Setup 6: 把 PyInstaller 产出封装成单文件安装包
run: choco install innosetup -y --no-progress
- name: 生成 Windows 安装包 (Inno Setup)
if: matrix.platform == 'windows'
# 从 frontend/package.json 读版本号传给 ISCC, 保持与 Release tag 一致
run: |
$ver = (Get-Content frontend/package.json | ConvertFrom-Json).version
echo "版本号: $ver"
ISCC.exe "/DMyAppVersion=$ver" packaging/tickflow.iss
# 把生成的 Setup.exe 移到工作区根 (Release 上传用)
Move-Item packaging/Output/TickFlowStockPanel-Setup-$ver.exe ${{ matrix.artifact }} -Force
shell: pwsh
- 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-Setup-x64.exe` → 双击安装向导,自动创建桌面/开始菜单快捷方式 |
| **macOS** | `TickFlowStockPanel-macos.zip` → 解压后右键打开 (绕过 Gatekeeper) |
| **Linux** | `TickFlowStockPanel-linux-x64.tar.gz` → 解压运行 |
### 说明
- 数据存储在用户目录 (Windows `%LOCALAPPDATA%`、mac `~/Library`、Linux `~/.local/share`), 卸载重装不丢数据
- 含纯 Polars 回测引擎; 不含 vectorbt 回测 (为控制体积)
- 系统通知: 设置 → 实时监控 → 系统通知
- 检查更新: 设置 → 系统设置 → 关于