Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# GitHub Actions 工作流说明

本项目包含两个主要的GitHub Actions工作流文件:

## 1. build.yml - 自动构建工作流

### 触发条件
- 推送到 `main` 或 `develop` 分支
- 向 `main` 分支提交Pull Request
- 手动触发 (workflow_dispatch)

### 功能
- 自动构建Windows、macOS和Linux平台的安装包
- 使用Poetry管理依赖
- 构建产物保存为artifacts,保留30天

### 构建平台
- **Windows**: 生成Windows可执行文件和安装包
- **macOS**: 生成macOS应用程序包
- **Linux**: 生成Linux可执行文件

## 2. release.yml - 自动发布工作流

### 触发条件
- 推送带有 `v*` 格式的标签 (如: v1.0.2)
- 手动触发,需要输入版本号

### 功能
1. **版本准备**:
- 自动更新 `pyproject.toml` 中的版本号
- 更新 `config/version.json` 中的版本信息
- 提交版本更新到仓库

2. **多平台构建**:
- 并行构建Windows、macOS、Linux安装包
- 创建压缩包便于分发

3. **自动发布**:
- 创建GitHub Release
- 上传所有平台的安装包
- 生成中英文发布说明

### 发布包命名
- Windows: `StreamCap-Windows-x64.zip`
- macOS: `StreamCap-macOS-x64.zip`
- Linux: `StreamCap-Linux-x64.tar.gz`

## 使用方法

### 自动构建
每次向主分支推送代码时,会自动触发构建流程。

### 发布新版本
有两种方式发布新版本:

#### 方法1: 创建标签 (推荐)
```bash
git tag v1.0.2
git push origin v1.0.2
```

#### 方法2: 手动触发
1. 进入GitHub仓库的Actions页面
2. 选择"Release"工作流
3. 点击"Run workflow"
4. 输入版本号 (如: v1.0.2)
5. 点击"Run workflow"

## 注意事项

1. **版本号格式**: 必须以 `v` 开头,如 `v1.0.2`
2. **权限要求**: 需要仓库的写权限来创建release和推送版本更新
3. **依赖管理**: 使用Poetry管理Python依赖,确保pyproject.toml配置正确
4. **构建时间**: 多平台构建可能需要10-20分钟完成

## 故障排除

如果构建失败,请检查:
1. pyproject.toml中的依赖配置是否正确
2. Python版本兼容性 (当前使用Python 3.11)
3. Flet框架版本是否支持目标平台
4. 系统依赖是否正确安装 (特别是Linux平台的GTK依赖)
116 changes: 116 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Build

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-windows:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Build Windows app
run: |
poetry run flet build windows --verbose

- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: windows-build
path: dist/
retention-days: 30

build-macos:
runs-on: macos-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Build macOS app
run: |
poetry run flet build macos --verbose

- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: macos-build
path: dist/
retention-days: 30

build-linux:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Build Linux app
run: |
poetry run flet build linux --verbose

- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: linux-build
path: dist/
retention-days: 30
Loading
Loading