Files
readflow/.gitea/workflows/build.yml
大麦 41508bcc7f
Some checks failed
Build Windows / Build Windows (push) Failing after 8m30s
ci: 修复 xwin 编译 - 添加 Windows MSVC 目标
问题:
- 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

93 lines
3.0 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build Windows
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build Windows
runs-on: ubuntu-latest
steps:
- name: Install Rust
run: |
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
run: |
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-msvc/release/readflow.exe dist/
cd dist
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="${GITEA_REF_NAME}"
TOKEN="${GITEA_TOKEN}"
URL="${GITEA_SERVER_URL}"
REPO="${GITEA_REPOSITORY}"
# Get or create release
RELEASE=$(curl -s "${URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${TOKEN}")
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 "${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: ${{ github.ref_name }}