|
| 1 | +name: Build Rust Binary |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +jobs: |
| 7 | + build: |
| 8 | + name: Build on ${{ matrix.os }} for ${{ matrix.target }} |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + include: |
| 13 | + - os: ubuntu-latest |
| 14 | + target: x86_64-unknown-linux-gnu |
| 15 | + - os: ubuntu-latest |
| 16 | + target: x86_64-pc-windows-msvc |
| 17 | + - os: macos-latest |
| 18 | + target: x86_64-apple-darwin |
| 19 | + - os: macos-latest |
| 20 | + target: aarch64-apple-darwin |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Install Rust |
| 26 | + uses: actions-rs/toolchain@v1 |
| 27 | + with: |
| 28 | + toolchain: stable |
| 29 | + target: ${{ matrix.target }} |
| 30 | + override: true |
| 31 | + |
| 32 | + - name: Cache Rust dependencies |
| 33 | + uses: Swatinem/rust-cache@v2 |
| 34 | + |
| 35 | + - name: Install cross (for Windows build) |
| 36 | + if: matrix.target == 'x86_64-pc-windows-msvc' |
| 37 | + run: cargo install cross |
| 38 | + |
| 39 | + - name: Set build flags |
| 40 | + id: build_flags |
| 41 | + run: | |
| 42 | + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then |
| 43 | + echo "::set-output name=flags::--release" |
| 44 | + echo "::set-output name=build_type::release" |
| 45 | + else |
| 46 | + echo "::set-output name=flags::" |
| 47 | + echo "::set-output name=build_type::debug" |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Build (non-Windows, non-aarch64-apple) |
| 51 | + if: matrix.target != 'x86_64-pc-windows-msvc' && matrix.target != 'aarch64-apple-darwin' |
| 52 | + run: cargo build ${{ steps.build_flags.outputs.flags }} --target ${{ matrix.target }} |
| 53 | + |
| 54 | + - name: Build (aarch64-apple-darwin) |
| 55 | + if: matrix.target == 'aarch64-apple-darwin' |
| 56 | + run: SDKROOT=$(xcrun -sdk macosx --show-sdk-path) MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version) cargo build ${{ steps.build_flags.outputs.flags }} --target ${{ matrix.target }} |
| 57 | + |
| 58 | + - name: Build (Windows) |
| 59 | + if: matrix.target == 'x86_64-pc-windows-msvc' |
| 60 | + run: cross build ${{ steps.build_flags.outputs.flags }} --target ${{ matrix.target }} |
| 61 | + |
| 62 | + - name: Upload artifact |
| 63 | + uses: actions/upload-artifact@v2 |
| 64 | + with: |
| 65 | + name: ${{ steps.build_flags.outputs.build_type }}-binary-${{ matrix.target }} |
| 66 | + path: | |
| 67 | + target/${{ matrix.target }}/${{ steps.build_flags.outputs.build_type }}/webview_deno_rust* |
| 68 | + !target/${{ matrix.target }}/${{ steps.build_flags.outputs.build_type }}/deps |
| 69 | + !target/${{ matrix.target }}/${{ steps.build_flags.outputs.build_type }}/build |
| 70 | + !target/${{ matrix.target }}/${{ steps.build_flags.outputs.build_type }}/.fingerprint |
| 71 | + retention-days: 7 |
0 commit comments