From e321271734e8d968154dacad62b9af2284f8ad9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E9=BA=A6?= Date: Tue, 10 Mar 2026 16:57:28 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=BF=AE=E5=A4=8D=20Gitea=20Actions=20-?= =?UTF-8?q?=20=E7=A7=BB=E9=99=A4=20GitHub=20=E4=B8=93=E7=94=A8=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:dtolnay/rust-action 需要 GitHub 认证 解决:使用基础命令安装 Rust 修复内容: - 使用 rustup 官方脚本安装 Rust - 使用 apt 安装 MinGW 和 GTK 依赖 - 使用 Gitea API 直接上传 Release --- .gitea/workflows/build.yml | 71 ++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index ec91ea5..3188609 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build Release +name: Build Windows on: push: @@ -15,53 +15,66 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Rust + - name: Install Rust run: | - rustup toolchain install stable --profile minimal --target x86_64-pc-windows-gnu + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal + source $HOME/.cargo/env 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 + sudo apt-get install -y mingw-w64 x86_64-w64-mingw32-posix-runtime libssl-dev pkg-config + + - name: Install GTK dependencies run: | + sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev libjavascriptcoregtk-4.0-dev libsoup2.4-dev + + - name: Build + run: | + source $HOME/.cargo/env + export CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc 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 + echo "ReadFlow for Windows" > README.txt + echo "Version: ${{ github.ref_name }}" >> README.txt + echo "" >> README.txt + echo "Usage: Double click readflow.exe" >> README.txt + zip -r readflow-windows-x86_64.zip readflow.exe README.txt - name: Upload to Release + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_URL: http://192.168.120.110:4000 + REPO: damai/readflow + TAG: ${{ github.ref_name }} run: | - TAG="${{ github.ref_name }}" - TOKEN="${{ secrets.GITEA_TOKEN }}" + # Get release by tag + RELEASE=$(curl -s "${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" \ + -H "Authorization: token ${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') + RELEASE_ID=$(echo $RELEASE | jq -r '.id') - if [ "$RELEASE_ID" != "null" ]; then - echo "Release exists: ${RELEASE_ID}" - else - echo "Creating new release" + if [ "$RELEASE_ID" == "null" ]; then + # Create release + RELEASE_ID=$(curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases" \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + -d "{\"tag_name\": \"${TAG}\", \"name\": \"ReadFlow ${TAG}\", \"body\": \"Release ${TAG}\", \"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" \ - -H "Authorization: token ${TOKEN}" \ + curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=readflow-windows-x86_64.zip" \ + -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/zip" \ --data-binary @dist/readflow-windows-x86_64.zip + + echo "Upload completed!"