9 Commits

Author SHA1 Message Date
大麦
e9a5f0a57e ci: 添加最小化测试 workflow
Some checks failed
Build Windows / Build Windows (push) Failing after 3s
Test Workflow / Test Environment (push) Successful in 3s
目的:
- 诊断 Gitea Actions 环境变量
- 检查可用命令
- 测试网络连接
2026-03-10 19:46:55 +08:00
大麦
075eedc13b ci: 使用 git clone 替代 actions/checkout
Some checks failed
Build Windows / Build Windows (push) Failing after 2s
原因:
- actions/checkout@v4 可能在 Gitea 中不兼容

修复:
- 使用 git clone 直接获取代码
- 使用 ${{ gitea.sha }} 指定 commit
2026-03-10 19:46:20 +08:00
大麦
5b3d1af415 ci: 修复 Gitea Actions 语法 + 添加 checkout 步骤
Some checks failed
Build Windows / Build Windows (push) Failing after 36s
问题:
- Gitea Actions 使用 ${{ gitea.xxx }} 而非 ${{ github.xxx }}
- 缺少 actions/checkout@v4 步骤获取代码

修复:
- 添加 checkout 步骤
- 修正 Gitea 语法
2026-03-10 19:40:12 +08:00
大麦
41508bcc7f ci: 修复 xwin 编译 - 添加 Windows MSVC 目标
Some checks failed
Build Windows / Build Windows (push) Failing after 8m30s
问题:
- xwin 编译时需要 x86_64-pc-windows-msvc 目标
- 错误:can't find crate for std

修复:
- 在安装 xwin 前添加 rustup target add x86_64-pc-windows-msvc
- 使用官方 xwin crate(非 git 版本)
- 添加 xwin download 步骤下载预编译 CRT
2026-03-10 19:28:48 +08:00
大麦
7af1c37577 ci: 使用 xwin 代替 MinGW
Some checks failed
Build Windows / Build Windows (push) Failing after 18m42s
问题:
- apt-get 安装 MinGW 依赖失败
- x86_64-w64-mingw32-posix-runtime 包不存在

解决方案:
- 使用 xwin 下载预编译的 MinGW CRT
- 使用 Cargo 安装 xwin 工具链
- 专门针对 Windows MSVC 编译

优势:
- 无需系统安装 MinGW
- 预编译的 CRT 更稳定
- Rust 标准的交叉编译方式
2026-03-10 18:23:17 +08:00
大麦
f8cd6b1d17 ci: 修复 MinGW 包名错误
Some checks failed
Build Windows / Build Windows (push) Failing after 15m35s
- 使用正确的 Debian 包名:gcc-mingw-w64-x86-64
- 移除不存在的 x86_64-w64-mingw32-posix-runtime 包
2026-03-10 18:03:23 +08:00
大麦
df48965e02 ci: 修复 Runner 无 sudo 问题
Some checks failed
Build Windows / Build Windows (push) Failing after 1m11s
- 移除所有 sudo 命令(容器以 root 运行)
- apt-get 不需要 sudo
2026-03-10 17:55:49 +08:00
大麦
cd19407f29 ci: 完全不依赖 GitHub 的 workflow
Some checks failed
Build Windows / Build Windows (push) Failing after 5m35s
- 使用 git clone 代替 actions/checkout
- 所有操作使用基础命令
- 不依赖任何 GitHub Actions

适用场景:
- Gitea Actions 无法访问 GitHub
- 完全离线环境
- 安全要求高的环境
2026-03-10 17:04:09 +08:00
大麦
e321271734 ci: 修复 Gitea Actions - 移除 GitHub 专用 action
Some checks failed
Build Windows / Build Windows (push) Failing after 41s
问题:dtolnay/rust-action 需要 GitHub 认证
解决:使用基础命令安装 Rust

修复内容:
- 使用 rustup 官方脚本安装 Rust
- 使用 apt 安装 MinGW 和 GTK 依赖
- 使用 Gitea API 直接上传 Release
2026-03-10 16:57:28 +08:00
2 changed files with 103 additions and 36 deletions

View File

@@ -1,67 +1,99 @@
name: Build Release
name: Build Windows
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-windows:
build:
name: Build Windows
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust
# 使用 git clone 而非 actions/checkout
- name: Clone repository
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
URL="${GITEA_SERVER_URL}/${GITEA_REPOSITORY}.git"
git clone $URL .
git checkout ${{ gitea.sha }}
- name: Install Rust
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64 x86_64-w64-mingw32-posix-runtime
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
source $HOME/.cargo/env
# 添加 Windows MSVC 目标xwin 需要)
rustup target add x86_64-pc-windows-msvc
- name: Install xwin (MinGW CRT)
run: |
source $HOME/.cargo/env
# 安装 xwin需要 x86_64-pc-windows-msvc 目标)
cargo install xwin
- name: Download MinGW CRT
run: |
source $HOME/.cargo/env
# 下载预编译的 MinGW CRT
xwin download --accept-license
- 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
source $HOME/.cargo/env
# 设置 xwin 环境变量
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER=xwin-link
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_AR=xwin-lib
export CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RANLIB=true
# 使用 xwin 提供的 SDK
export XWIN_PATH=$HOME/.cache/xwin
cargo build --release --target x86_64-pc-windows-msvc
- name: Package
run: |
mkdir -p dist
cp target/x86_64-pc-windows-gnu/release/readflow.exe dist/
cp target/x86_64-pc-windows-msvc/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
echo "ReadFlow for Windows" > README.txt
echo "Version: ${GITEA_REF_NAME}" >> README.txt
echo "Built with: xwin + MSVC" >> README.txt
echo "Date: $(date)" >> README.txt
zip -r readflow-windows-x86_64.zip readflow.exe README.txt
- name: Upload to Release
run: |
TAG="${{ github.ref_name }}"
TOKEN="${{ secrets.GITEA_TOKEN }}"
TAG="${GITEA_REF_NAME}"
TOKEN="${GITEA_TOKEN}"
URL="${GITEA_SERVER_URL}"
REPO="${GITEA_REPOSITORY}"
# 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')
RELEASE=$(curl -s "${URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${TOKEN}")
if [ "$RELEASE_ID" != "null" ]; then
echo "Release exists: ${RELEASE_ID}"
else
echo "Creating new release"
RELEASE_ID=$(echo $RELEASE | jq -r '.id')
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
RELEASE_ID=$(curl -s -X POST "${URL}/api/v1/repos/${REPO}/releases" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"name\": \"ReadFlow ${TAG}\", \"body\": \"Release ${TAG}\\n\\nBuilt with xwin (预编译 MinGW CRT)\", \"draft\": false}" \
| jq -r '.id')
fi
echo "Release ID: ${RELEASE_ID}"
# Upload asset
curl -s -X POST "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases/${RELEASE_ID}/assets" \
curl -s -X POST "${URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=readflow-windows-x86_64.zip" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/zip" \
--data-binary @dist/readflow-windows-x86_64.zip
echo "✅ Upload completed!"
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_SERVER_URL: http://192.168.120.110:4000
GITEA_REPOSITORY: damai/readflow
GITEA_REF_NAME: ${{ gitea.ref_name }}

35
.gitea/workflows/test.yml Normal file
View File

@@ -0,0 +1,35 @@
name: Test Workflow
on:
push:
tags:
- 'v*'
jobs:
test:
name: Test Environment
runs-on: ubuntu-latest
steps:
- name: Print environment variables
run: |
echo "=== Environment Variables ==="
echo "GITEA_REF_NAME: ${{ gitea.ref_name }}"
echo "GITEA_SHA: ${{ gitea.sha }}"
echo "GITEA_REPOSITORY: ${{ gitea.repository }}"
echo "GITEA_TOKEN: ${GITEA_TOKEN:0:10}..."
echo "GITEA_SERVER_URL: $GITEA_SERVER_URL"
echo "GITEA_REPOSITORY: $GITEA_REPOSITORY"
echo ""
# 检查可用命令
echo "=== Available Commands ==="
which git && echo "✅ git available" || echo "❌ git not found"
which curl && echo "✅ curl available" || echo "❌ curl not found"
which zip && echo "✅ zip available" || echo "❌ zip not found"
which jq && echo "✅ jq available" || echo "❌ jq not found"
echo ""
# 检查网络
echo "=== Network Test ==="
curl -I https://sh.rustup.rs | head -1