|
| 1 | +name: Windows Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + CARGO_TERM_COLOR: always |
| 10 | + FLUTTER_VERSION: '3.38.0' |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-windows: |
| 14 | + runs-on: windows-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Rust |
| 19 | + uses: dtolnay/rust-toolchain@stable |
| 20 | + |
| 21 | + - name: Setup Flutter |
| 22 | + uses: subosito/flutter-action@v2 |
| 23 | + with: |
| 24 | + flutter-version: ${{ env.FLUTTER_VERSION }} |
| 25 | + channel: stable |
| 26 | + |
| 27 | + - name: Cache Cargo |
| 28 | + uses: Swatinem/rust-cache@v2 |
| 29 | + with: |
| 30 | + shared-key: rust-windows-release |
| 31 | + |
| 32 | + - name: Install flutter_rust_bridge_codegen |
| 33 | + run: cargo install flutter_rust_bridge_codegen |
| 34 | + |
| 35 | + - name: Get Flutter dependencies |
| 36 | + working-directory: packages/fula_client |
| 37 | + run: flutter pub get |
| 38 | + |
| 39 | + - name: Generate Rust bindings |
| 40 | + run: flutter_rust_bridge_codegen generate |
| 41 | + |
| 42 | + - name: Build Windows DLL |
| 43 | + run: cargo build -p fula-flutter --release |
| 44 | + |
| 45 | + - name: Upload Windows DLL artifact |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: windows-x86_64 |
| 49 | + path: target/release/fula_flutter.dll |
| 50 | + retention-days: 1 |
| 51 | + |
| 52 | + attach-to-release: |
| 53 | + needs: build-windows |
| 54 | + runs-on: ubuntu-latest |
| 55 | + steps: |
| 56 | + - name: Determine release tag |
| 57 | + id: tag |
| 58 | + run: | |
| 59 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 60 | + echo "tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT |
| 61 | + else |
| 62 | + TAG=$(gh api repos/${{ github.repository }}/releases/latest --jq .tag_name) |
| 63 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 64 | + fi |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Download Windows DLL artifact |
| 69 | + uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + name: windows-x86_64 |
| 72 | + path: windows-libs/ |
| 73 | + |
| 74 | + - name: Package Windows libs |
| 75 | + run: cd windows-libs && zip -r ../windows-libs.zip . |
| 76 | + |
| 77 | + - name: Upload to GitHub Release |
| 78 | + uses: softprops/action-gh-release@v1 |
| 79 | + with: |
| 80 | + tag_name: ${{ steps.tag.outputs.tag }} |
| 81 | + files: windows-libs.zip |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments