From 3a6f2f29cd988624d72a5ba9c77d6f01bc471249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E9=BA=A6?= Date: Tue, 10 Mar 2026 16:08:21 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B7=BB=E5=8A=A0=20Gitea=20Actions=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=BC=96=E8=AF=91=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 支持 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 --- .gitea/workflows/release.yml | 197 +++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 .gitea/workflows/release.yml diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..5ee3fa2 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,197 @@ +name: Release Build + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: 1 + +jobs: + build-windows: + name: Build Windows + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + target: x86_64-pc-windows-gnu + profile: minimal + components: rustfmt, clippy + + - name: Install MinGW + run: sudo apt-get update && sudo apt-get install -y mingw-w64 + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ubuntu-cargo-registry-windows-${{ hashFiles('**/Cargo.lock') }} + + - name: Build release + run: cargo build --release --target x86_64-pc-windows-gnu + + - name: Package Windows + run: | + mkdir -p release + cp target/x86_64-pc-windows-gnu/release/readflow.exe release/ + # Create README + cat > release/README.txt << 'EOF' + ReadFlow v${{ github.ref_name }} for Windows + + 快速开始: + 1. 解压到任意目录 + 2. 双击运行 readflow.exe + + 功能: + - EPUB/MOBI/Markdown/PDF 阅读 + - 20+ 编程语言语法高亮 + - 双语翻译对照 + - 笔记与书签系统 + - 插件系统 + - 主题商店 + + 技术支持:damai@foshanhuiya.com + EOF + cd release + zip -r ../readflow-${{ github.ref_name }}-windows-x86_64.zip . + + - name: Upload to Release + uses: softprops/action-gh-release@v2 + with: + name: Windows x86_64 + files: readflow-${{ github.ref_name }}-windows-x86_64.zip + tag_name: ${{ github.ref_name }} + token: ${{ secrets.GITEA_TOKEN }} + fail_on_unmatched_files: true + env: + GITHUB_SERVER_URL: http://192.168.120.110:4000 + GITHUB_REPOSITORY: damai/readflow + + build-linux: + name: Build Linux + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + target: x86_64-unknown-linux-gnu + profile: minimal + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf + + - name: Build release + run: cargo build --release --target x86_64-unknown-linux-gnu + + - name: Package Linux + run: | + mkdir -p release + cp target/x86_64-unknown-linux-gnu/release/readflow release/ + chmod +x release/readflow + # Create .desktop file + cat > release/readflow.desktop << 'EOF' + [Desktop Entry] + Name=ReadFlow + Comment=ReadFlow - 面向开发者和知识工作者的阅读工具 + Exec=readflow + Icon=readflow + Terminal=false + Type=Application + Categories=Utility;Reading; + EOF + cd release + tar -czf ../readflow-${{ github.ref_name }}-linux-x86_64.tar.gz readflow readflow.desktop + + - name: Upload to Release + uses: softprops/action-gh-release@v2 + with: + name: Linux x86_64 + files: readflow-${{ github.ref_name }}-linux-x86_64.tar.gz + tag_name: ${{ github.ref_name }} + token: ${{ secrets.GITEA_TOKEN }} + fail_on_unmatched_files: true + env: + GITHUB_SERVER_URL: http://192.168.120.110:4000 + GITHUB_REPOSITORY: damai/readflow + + build-macos: + name: Build macOS + runs-on: macos-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Rust toolchain + uses: actions-rs/toolchain@v1 + with: + target: x86_64-apple-darwin + profile: minimal + + - name: Build release + run: cargo build --release --target x86_64-apple-darwin + + - name: Package macOS + run: | + mkdir -p release/ReadFlow.app/Contents/MacOS + mkdir -p release/ReadFlow.app/Contents/Resources + cp target/release/readflow release/ReadFlow.app/Contents/MacOS/ + chmod +x release/ReadFlow.app/Contents/MacOS/readflow + + # Create Info.plist + cat > release/ReadFlow.app/Contents/Info.plist << 'EOF' + + + + + CFBundleExecutable + readflow + CFBundleIdentifier + com.readflow.app + CFBundleName + ReadFlow + CFBundleDisplayName + ReadFlow + CFBundleShortVersionString + ${{ github.ref_name }} + CFBundleVersion + ${{ github.ref_name }} + CFBundlePackageType + APPL + NSHighResolutionCapable + + + + EOF + + # Copy assets + if [ -d "assets" ]; then + cp -r assets release/ReadFlow.app/Contents/Resources/ + fi + + cd release + zip -r -X ../readflow-${{ github.ref_name }}-macos-x86_64.zip ReadFlow.app + + - name: Upload to Release + uses: softprops/action-gh-release@v2 + with: + name: macOS x86_64 + files: readflow-${{ github.ref_name }}-macos-x86_64.zip + tag_name: ${{ github.ref_name }} + token: ${{ secrets.GITEA_TOKEN }} + fail_on_unmatched_files: true + env: + GITHUB_SERVER_URL: http://192.168.120.110:4000 + GITHUB_REPOSITORY: damai/readflow