|
| 1 | +name: Build Rust Project |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build on ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - os: ubuntu-latest |
| 19 | + target: x86_64-unknown-linux-gnu |
| 20 | + artifact_name: mc-oauth |
| 21 | + asset_name: mc-oauth-linux-amd64 |
| 22 | + |
| 23 | + - os: ubuntu-latest |
| 24 | + target: aarch64-unknown-linux-gnu |
| 25 | + artifact_name: mc-oauth |
| 26 | + asset_name: mc-oauth-linux-arm |
| 27 | + |
| 28 | + - os: windows-latest |
| 29 | + target: x86_64-pc-windows-gnu |
| 30 | + artifact_name: mc-oauth.exe |
| 31 | + asset_name: mc-oauth-windows-amd64.exe |
| 32 | + |
| 33 | + - os: windows-latest |
| 34 | + target: aarch64-pc-windows-msvc |
| 35 | + artifact_name: mc-oauth.exe |
| 36 | + asset_name: mc-oauth-windows-arm.exe |
| 37 | + |
| 38 | + - os: macos-latest |
| 39 | + target: x86_64-apple-darwin |
| 40 | + artifact_name: mc-oauth |
| 41 | + asset_name: mc-oauth-macos-amd64 |
| 42 | + |
| 43 | + - os: macos-latest |
| 44 | + target: aarch64-apple-darwin |
| 45 | + artifact_name: mc-oauth |
| 46 | + asset_name: mc-oauth-macos-arm |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - name: Install Rust |
| 52 | + run: rustup toolchain install stable --profile minimal |
| 53 | + |
| 54 | + - name: Add target |
| 55 | + run: rustup target add ${{ matrix.target }} |
| 56 | + |
| 57 | + - name: Install Linux ARM dependencies |
| 58 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 59 | + run: | |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu |
| 62 | +
|
| 63 | + - name: Set linker for Linux ARM |
| 64 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 65 | + run: | |
| 66 | + echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml |
| 67 | + echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml |
| 68 | +
|
| 69 | + - uses: Swatinem/rust-cache@v2 |
| 70 | + with: |
| 71 | + prefix-key: "v0-rust" |
| 72 | + shared-key: "${{ matrix.target }}" |
| 73 | + cache-on-failure: "true" |
| 74 | + cache-all-crates: "true" |
| 75 | + workspaces: | |
| 76 | + . -> target |
| 77 | + cache-targets: "true" |
| 78 | + |
| 79 | + - name: Build |
| 80 | + uses: actions-rs/cargo@v1 |
| 81 | + with: |
| 82 | + command: build |
| 83 | + args: --release --target ${{ matrix.target }} |
| 84 | + |
| 85 | + - name: Upload artifact |
| 86 | + uses: actions/upload-artifact@v4 |
| 87 | + with: |
| 88 | + name: ${{ matrix.asset_name }} |
| 89 | + path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }} |
0 commit comments