|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: "*" |
| 6 | + paths: |
| 7 | + - "**/*.rs" |
| 8 | + - "Cargo.toml" |
| 9 | + - "Cargo.lock" |
| 10 | + - ".cargo/config.toml" |
| 11 | + - ".github/workflows/build.yml" |
| 12 | + tags: "*" |
| 13 | + pull_request: |
| 14 | + branches: "*" |
| 15 | + paths: |
| 16 | + - "**/*.rs" |
| 17 | + - "Cargo.toml" |
| 18 | + - "Cargo.lock" |
| 19 | + - ".cargo/config.toml" |
| 20 | + - ".github/workflows/build.yml" |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + name: ${{ matrix.kind }} ${{ matrix.os }} |
| 25 | + runs-on: ${{ matrix.os }} |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + os: |
| 29 | + - ubuntu-latest |
| 30 | + # - ubuntu-24.04-arm |
| 31 | + - macOS-13 # Intel |
| 32 | + - macOS-latest # Apple Silicon |
| 33 | + - windows-latest |
| 34 | + |
| 35 | + env: |
| 36 | + CARGO_INCREMENTAL: 0 |
| 37 | + RUST_BACKTRACE: full |
| 38 | + CARGO_TERM_COLOR: always |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Clone repository |
| 42 | + uses: actions/checkout@v3 |
| 43 | + |
| 44 | + - name: Install system dependencies |
| 45 | + if: startsWith(matrix.os, 'ubuntu') |
| 46 | + run: | |
| 47 | + sudo apt-get update |
| 48 | + sudo apt-get install -y \ |
| 49 | + gcc g++ clang libfontconfig-dev libwayland-dev \ |
| 50 | + libwebkit2gtk-4.1-dev libxkbcommon-x11-dev \ |
| 51 | + libssl-dev libzstd-dev \ |
| 52 | + vulkan-validationlayers libvulkan1 |
| 53 | +
|
| 54 | + - name: Install stable toolchain |
| 55 | + uses: actions-rs/toolchain@v1 |
| 56 | + with: |
| 57 | + profile: minimal |
| 58 | + toolchain: stable |
| 59 | + override: true |
| 60 | + components: rustfmt, clippy |
| 61 | + |
| 62 | + - name: Log versions |
| 63 | + run: | |
| 64 | + rustc --version |
| 65 | + cargo --version |
| 66 | +
|
| 67 | + - name: Cache |
| 68 | + uses: actions/cache@v3 |
| 69 | + with: |
| 70 | + path: |- |
| 71 | + ~/.cargo/registry/index/ |
| 72 | + ~/.cargo/registry/cache/ |
| 73 | + ~/.cargo/git/db/ |
| 74 | + target/*/.* |
| 75 | + target/*/build |
| 76 | + target/*/deps |
| 77 | + key: |
| 78 | + ${{ matrix.config.os }}-${{ hashFiles('Cargo.lock') }} |
| 79 | + restore-keys: | |
| 80 | + ${{ matrix.config.os }}- |
| 81 | +
|
| 82 | + - name: Run cargo fmt |
| 83 | + run: cargo fmt --all -- --check |
| 84 | + |
| 85 | + - name: Run cargo check |
| 86 | + run: cargo check --locked |
| 87 | + |
| 88 | + - name: Run cargo clippy |
| 89 | + run: cargo clippy -- -D warnings |
| 90 | + |
| 91 | + - name: Run cargo test |
| 92 | + run: cargo test --locked |
| 93 | + |
| 94 | + - name: Build release |
| 95 | + run: cargo build --release --locked |
| 96 | + |
| 97 | + - name: Package release |
| 98 | + run: cargo packager --release |
| 99 | + |
| 100 | + - name: Pre-release (linux x86_64) |
| 101 | + if: matrix.os == 'ubuntu-latest' |
| 102 | + run: zip -r memory-match-game-x86_64-unknown-linux-gnu.zip memory-match-game |
| 103 | + working-directory: target/release |
| 104 | + |
| 105 | + - name: Pre-release (linux aarch64) |
| 106 | + if: matrix.os == 'ubuntu-24.04-arm' |
| 107 | + run: zip -r memory-match-game-aarch64-unknown-linux-gnu.zip memory-match-game |
| 108 | + working-directory: target/release |
| 109 | + |
| 110 | + - name: Pre-release (mac) |
| 111 | + if: matrix.os == 'macOS-13' |
| 112 | + run: zip -r memory-match-game-x86_64-apple-darwin.zip memory-match-game |
| 113 | + working-directory: target/release |
| 114 | + |
| 115 | + - name: Pre-release (aarch64-apple-darwin) |
| 116 | + if: matrix.os == 'macOS-latest' |
| 117 | + run: zip -r memory-match-game-aarch64-apple-darwin.zip memory-match-game |
| 118 | + working-directory: target/release |
| 119 | + |
| 120 | + - name: Pre-release (windows x86_64) |
| 121 | + if: matrix.os == 'windows-latest' |
| 122 | + run: | |
| 123 | + Compress-Archive -CompressionLevel Optimal -Force -Path target/release/memory-match-game.exe -DestinationPath target/release/memory-match-game-x86_64-pc-windows-msvc.zip |
| 124 | +
|
| 125 | + - name: Release |
| 126 | + uses: softprops/action-gh-release@v1 |
| 127 | + if: | |
| 128 | + startsWith(github.repository, 'justjavac') && |
| 129 | + startsWith(github.ref, 'refs/tags/') |
| 130 | + env: |
| 131 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 132 | + with: |
| 133 | + files: | |
| 134 | + target/release/memory-match-game-x86_64-pc-windows-msvc.zip |
| 135 | + target/release/memory-match-game-x86_64-unknown-linux-gnu.zip |
| 136 | + target/release/memory-match-game-x86_64-apple-darwin.zip |
| 137 | + target/release/memory-match-game-aarch64-apple-darwin.zip |
| 138 | + target/release/memory-match-game-aarch64-unknown-linux-gnu.zip |
| 139 | + target/release/memory-match-game_*.dmg |
| 140 | + draft: true |
0 commit comments