Tauri Build (Windows) #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/tauri-build.yml | |
| name: Tauri Build (Windows) | |
| # 触发条件:检测到版本更新、手动触发 | |
| on: | |
| push: | |
| tags: [ 'v*' ] # 仅匹配v开头的Tag | |
| workflow_dispatch: # 保留手动触发,方便临时编译 | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| # 1. 拉取代码到GitHub Windows服务器 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 2. 安装Rust | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| target: x86_64-pc-windows-msvc # 本地Windows默认编译目标 | |
| # 3. 安装cargo-tauri CLI工具 | |
| - name: Install tauri-cli | |
| run: cargo install tauri-cli --locked | |
| # 4. 缓存Rust依赖 | |
| - name: Cache Rust dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: './src-tauri -> target' | |
| # 5. 编译命令 | |
| - name: Build Tauri app with cargo tauri build | |
| run: cargo tauri build | |
| working-directory: . # 确保在项目根目录执行 | |
| # 6. 上传Windows编译产物 | |
| - name: Upload Windows build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: viewstage-windows | |
| path: | | |
| # 产物路径和本地src-tauri/target/release/bundle完全一致 | |
| src-tauri/target/release/bundle/msi/*.msi | |
| src-tauri/target/release/bundle/exe/*.exe | |
| # 单独的可执行文件(本地target/release下的产物) | |
| src-tauri/target/release/ViewStage.exe | |
| # 7. 创建 GitHub Release 并上传构建产物 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| src-tauri/target/release/bundle/msi/*.msi | |
| src-tauri/target/release/bundle/exe/*.exe | |
| src-tauri/target/release/ViewStage.exe | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |