5 Commits

Author SHA1 Message Date
大麦
0dd7c30b62 ci: 简化 Gitea Actions workflow
Some checks failed
Build Release / Build Windows (push) Failing after 6m22s
- 使用更兼容的语法
- 简化编译步骤
- 直接使用 Gitea API 上传 Release 而不是 GitHub Actions
2026-03-10 16:52:25 +08:00
大麦
7cc5e141c7 ci: 优化 Gitea Actions Workflow 配置
Some checks failed
Release Build / Build Windows (push) Failing after 17s
Release Build / Build Linux (push) Failing after 55s
Release Build / Build macOS (push) Has been cancelled
- 添加 GITEA_TOKEN 全局变量
- 使用 dtolnay/rust-action 编译
- 安装必要依赖
- 使用 ncipollo/release-action 上传
- 修复上传问题
2026-03-10 16:46:41 +08:00
大麦
5c3e7ccbfd docs: 添加 Windows 交叉编译脚本和 Gitea Actions 配置指南
Some checks failed
Release Build / Build Windows (push) Failing after 3m18s
Release Build / Build Linux (push) Failing after 33s
Release Build / Build macOS (push) Has been cancelled
- scripts/build-windows.sh: Windows 交叉编译脚本
- docs/GITEA_ACTIONS.md: Gitea Actions Runner 配置指南

使用方式:
1. 配置 Gitea Actions Runner (参考 docs/GITEA_ACTIONS.md)
2. 或手动运行 ./scripts/build-windows.sh --upload
2026-03-10 16:10:51 +08:00
大麦
3a6f2f29cd ci: 添加 Gitea Actions 自动编译工作流
- 支持 Windows/Linux/macOS 三平台
- 使用交叉编译 (ubuntu + mingw)
- 自动打包并上传 Release
- 触发器:Git tag 推送

平台支持:
- Windows: x86_64-pc-windows-gnu (mingw)
- Linux: x86_64-unknown-linux-gnu
- macOS: x86_64-apple-darwin
2026-03-10 16:08:21 +08:00
大麦
1b0bff2beb ci: 添加 GitHub Actions 自动编译工作流
- 跨平台自动编译
- macOS (Intel/Apple Silicon)
- Linux (gnu/musl)
- Windows (msvc/gnu)
- 自动发布 Release

GitHub Actions 将自动编译所有平台版本并上传到 Release。
2026-03-10 15:59:37 +08:00
4 changed files with 559 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
name: Build Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-windows:
name: Build Windows
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
run: |
rustup toolchain install stable --profile minimal --target x86_64-pc-windows-gnu
rustup target add x86_64-pc-windows-gnu
cargo install --target x86_64-pc-windows-gnu cross 2>&1 || true
- name: Install MinGW
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64 x86_64-w64-mingw32-posix-runtime
- name: Build
env:
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: x86_64-w64-mingw32-gcc
run: |
cargo build --release --target x86_64-pc-windows-gnu
- name: Package
run: |
mkdir -p dist
cp target/x86_64-pc-windows-gnu/release/readflow.exe dist/
cd dist
zip -r -q readflow-windows-x86_64.zip readflow.exe
echo "ReadFlow Windows x86_64" > README.txt
echo "Build completed at $(date)" >> README.txt
zip -r -q readflow-windows-x86_64.zip README.txt
- name: Upload to Release
run: |
TAG="${{ github.ref_name }}"
TOKEN="${{ secrets.GITEA_TOKEN }}"
# Get or create release
RELEASE_ID=$(curl -s -X POST "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"name\": \"ReadFlow ${TAG}\", \"draft\": false, \"prerelease\": false}" \
| jq -r '.id')
if [ "$RELEASE_ID" != "null" ]; then
echo "Release exists: ${RELEASE_ID}"
else
echo "Creating new release"
fi
# Upload asset
curl -s -X POST "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/zip" \
--data-binary @dist/readflow-windows-x86_64.zip

184
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,184 @@
name: Release Build
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
build:
name: Build Release
strategy:
matrix:
include:
- os: macos-latest
target: x86_64-apple-darwin
name: macOS-Intel
archive: readflow-${{ github.ref_name }}-macos-x86_64.zip
- os: macos-latest
target: aarch64-apple-darwin
name: macOS-Apple-Silicon
archive: readflow-${{ github.ref_name }}-macos-aarch64.zip
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
name: Linux
archive: readflow-${{ github.ref_name }}-linux-x86_64.tar.gz
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
name: Linux-MUSL
archive: readflow-${{ github.ref_name }}-linux-x86_64-musl.tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
name: Windows
archive: readflow-${{ github.ref_name }}-windows-x86_64.zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
target: ${{ matrix.target }}
profile: minimal
components: rustfmt, clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v4
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build release
run: cargo build --release
- name: Run tests
run: cargo test
- name: Package macOS
if: matrix.name == 'macOS-Intel' || matrix.name == 'macOS-Apple-Silicon'
run: |
mkdir -p release
cp target/release/readflow release/
chmod +x release/readflow
# Create Info.plist
cat > release/Info.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>readflow</string>
<key>CFBundleIdentifier</key>
<string>com.readflow.app</string>
<key>CFBundleName</key>
<string>ReadFlow</string>
<key>CFBundleDisplayName</key>
<string>ReadFlow</string>
<key>CFBundleShortVersionString</key>
<string>${{ github.ref_name }}</string>
<key>CFBundleVersion</key>
<string>${{ github.ref_name }}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
cd release
mkdir -p ReadFlow.app/Contents/MacOS
mkdir -p ReadFlow.app/Contents/Resources
mv readflow ReadFlow.app/Contents/MacOS/
mv Info.plist ReadFlow.app/Contents/
cp -r ../assets ReadFlow.app/Contents/Resources/ || true
cd ..
zip -r -X ${{ matrix.archive }} ReadFlow.app
- name: Package Linux
if: matrix.name == 'Linux' || matrix.name == 'Linux-MUSL'
run: |
mkdir -p release
cp target/release/readflow release/readflow
chmod +x release/readflow
# Create .desktop file
cat > release/readflow.desktop << EOF
[Desktop Entry]
Name=ReadFlow
Comment=ReadFlow - 面向开发者和知识工作者的阅读工具
Exec=/usr/local/bin/readflow
Icon=readflow
Terminal=false
Type=Application
Categories=Utility;Reading;
EOF
cd release
if [ "${{ matrix.name }}" == "Linux-MUSL" ]; then
tar -czf ${{ matrix.archive }} readflow
else
tar -czf ${{ matrix.archive }} readflow readflow.desktop
fi
- name: Package Windows
if: matrix.name == 'Windows'
run: |
mkdir -p release
cp target/release/readflow.exe release/
# Create NSIS installer (simplified)
# For now, just create a simple wrapper script
cat > release/install.bat << 'EOF'
@echo off
echo Installing ReadFlow...
copy readflow.exe %LOCALAPPDATA%\readflow\
echo Installation complete!
EOF
cd release
powershell Compress-Archive -Path ${{ matrix.archive }} -DestinationPath . readflow.exe install.bat
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
name: ${{ matrix.name }}
files: |
${{ matrix.archive }}
body: |
## 🎉 ReadFlow ${{ github.ref_name }} for ${{ matrix.name }}
### 下载
- 下方附件中的安装包
### 快速开始
- 解压后运行 readflow 即可
### 功能
- ✅ EPUB/MOBI/Markdown/PDF 阅读
- ✅ 20+ 编程语言语法高亮
- ✅ 双语翻译对照
- ✅ 笔记与书签系统
- ✅ 插件系统
- ✅ 主题商店
---
**下载附件**: ${{ matrix.name }}
generate_release_notes: true
tag_name: ${{ github.ref_name }}
token: ${{ secrets.GITHUB_TOKEN }}
fail_on_unmatched_files: true

149
docs/GITEA_ACTIONS.md Normal file
View File

@@ -0,0 +1,149 @@
# Gitea Actions Runner 配置指南
## 概述
Gitea Actions 是 Gitea 的 CI/CD 系统,与 GitHub Actions 兼容。
## 配置步骤
### 1. 启用 Gitea Actions
编辑 Gitea 配置文件 (`/etc/gitea/app.ini``~/.gitea/conf/app.ini`):
```ini
[actions]
ENABLED = true
DEFAULT_ACTIONS_URL = github
```
重启 Gitea:
```bash
sudo systemctl restart gitea
```
### 2. 安装 Runner
#### macOS 安装
```bash
# 下载 Runner
mkdir -p ~/gitea-runner
cd ~/gitea-runner
curl -L https://github.com/actions/runner/releases/latest/download/actions-runner-darwin-x64-2.311.0.tar.gz -o runner.tar.gz
tar xzf runner.tar.gz
# 配置 Runner
./config.sh --url http://192.168.120.110:4000/damai/readflow \
--token <TOKEN_FROM_GITEA> \
--name macos-runner \
--runnergroup default
# 启动 Runner
./run.sh
```
#### Linux 安装
```bash
# 下载 Runner
mkdir -p ~/gitea-runner
cd ~/gitea-runner
curl -L https://github.com/actions/runner/releases/latest/download/actions-runner-linux-x64-2.311.0.tar.gz -o runner.tar.gz
tar xzf runner.tar.gz
# 配置 Runner
./config.sh --url http://192.168.120.110:4000/damai/readflow \
--token <TOKEN_FROM_GITEA> \
--name linux-runner \
--runnergroup default
# 启动 Runner
./run.sh
```
### 3. 获取 Runner Token
1. 访问 Gitea 仓库http://192.168.120.110:4000/damai/readflow
2. 进入 Settings → Actions
3. 点击 "Add runner"
4. 复制 Token
### 4. 验证 Runner
访问 Gitea 仓库的 Actions 页面,应该能看到注册的 Runner。
### 5. 触发编译
推送标签触发编译:
```bash
cd /Users/rong/.openclaw/workspace/readflow
git tag -a v0.2.1 -m "Release v0.2.1"
git push origin v0.2.1
```
---
## 工作流文件
工作流文件位于:`.gitea/workflows/release.yml`
支持的平台:
- ✅ Windows (x86_64-pc-windows-gnu)
- ✅ Linux (x86_64-unknown-linux-gnu)
- ✅ macOS (x86_64-apple-darwin)
---
## 故障排除
### Runner 无法连接
检查 Gitea 配置:
```ini
[actions]
ENABLED = true
DEFAULT_ACTIONS_URL = github
```
### 编译失败
检查 Runner 是否安装了必要的依赖:
```bash
# macOS
brew install rust mingw-w64
# Linux
sudo apt-get install rustc mingw-w64
```
### 查看日志
访问 Gitea 仓库的 Actions 页面查看编译日志。
---
## 快速开始
### 方案 1: 使用 Docker Runner (推荐)
```bash
docker run -d \
-e GITEA_INSTANCE_URL=http://192.168.120.110:4000 \
-e GITEA_RUNNER_REGISTRATION_TOKEN=<TOKEN> \
-e GITEA_RUNNER_NAME=docker-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
ghcr.io/gitea/act_runner:latest
```
### 方案 2: 本地安装 Runner
参考上面的安装步骤。
---
## 参考资料
- Gitea Actions 文档https://docs.gitea.io/usage/actions/
- Runner 下载https://github.com/actions/runner/releases
- Workflows 语法https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions

159
scripts/build-windows.sh Normal file
View File

@@ -0,0 +1,159 @@
#!/bin/bash
# Windows 交叉编译脚本
# 使用 x86_64-w64-mingw32 工具链
set -e
echo "🚀 ReadFlow Windows 交叉编译脚本"
echo "=================================="
# 颜色输出
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# 检查是否安装了 mingw 工具链
check_mingw() {
if command -v x86_64-w64-mingw32-gcc &> /dev/null; then
log_info "MinGW 工具链已安装"
return 0
else
log_error "MinGW 工具链未安装"
log_info "请运行以下命令安装:"
echo " brew install mingw-w64 # macOS"
echo " sudo apt-get install mingw-w64 # Linux"
return 1
fi
}
# 添加 Windows 目标
add_target() {
log_info "添加 Windows 目标..."
rustup target add x86_64-pc-windows-gnu
}
# 编译
build() {
log_info "开始编译 Windows 版本..."
# 设置交叉编译器
export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc
# 编译
cargo build --release --target x86_64-pc-windows-gnu
log_info "编译完成!"
}
# 打包
package() {
log_info "打包 Windows 版本..."
local version="0.2.0"
local build_dir="target/x86_64-pc-windows-gnu/release"
local package_dir="dist/readflow-${version}-windows-x86_64"
mkdir -p "${package_dir}"
# 复制可执行文件
cp "${build_dir}/readflow.exe" "${package_dir}/"
# 创建 README
cat > "${package_dir}/README.txt" << EOF
ReadFlow v${version} for Windows
快速开始:
1. 解压到任意目录
2. 双击运行 readflow.exe
功能:
- EPUB/MOBI/Markdown/PDF 阅读
- 20+ 编程语言语法高亮
- 双语翻译对照
- 笔记与书签系统
- 插件系统
- 主题商店
技术支持damai@foshanhuiya.com
Gitea: http://192.168.120.110:4000/damai/readflow
EOF
# 创建 ZIP
cd dist
zip -r "readflow-${version}-windows-x86_64.zip" "readflow-${version}-windows-x86_64/"
cd ..
log_info "打包完成dist/readflow-${version}-windows-x86_64.zip"
}
# 上传到 Release
upload_release() {
log_info "上传到 Gitea Release..."
local version="0.2.0"
local token="884162096b7f331c6fb236217d00a9452e34d4aa"
local file="dist/readflow-${version}-windows-x86_64.zip"
# 获取 Release ID
local release_id=$(curl -s "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases/tags/v${version}" \
-H "Authorization: token ${token}" | jq -r '.id')
if [ "$release_id" == "null" ] || [ -z "$release_id" ]; then
log_error "Release v${version} 不存在"
return 1
fi
log_info "Release ID: ${release_id}"
# 上传文件
curl -L -X POST "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases/${release_id}/assets?name=readflow-${version}-windows-x86_64.zip" \
-H "Authorization: token ${token}" \
-H "Content-Type: application/zip" \
--data-binary @"${file}"
log_info "上传完成!"
}
# 主函数
main() {
log_info "开始 Windows 交叉编译..."
# 检查工具链
if ! check_mingw; then
log_warn "跳过编译,请安装 MinGW 后重试"
exit 1
fi
# 添加目标
add_target
# 编译
build
# 打包
package
# 上传 (可选)
if [ "$1" == "--upload" ]; then
upload_release
fi
log_info "🎉 Windows 打包完成!"
log_info "文件位置dist/readflow-0.2.0-windows-x86_64.zip"
}
# 运行
main "$@"