|
| 1 | +name: Rust |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - 'master' |
| 8 | + tags: |
| 9 | + - '*' |
| 10 | + |
| 11 | +# The colors mess with the problem matcher. |
| 12 | +# env: |
| 13 | + # CARGO_TERM_COLOR: always |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: ${{ matrix.os }} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + label: |
| 22 | + - Windows aarch64 |
| 23 | + - Windows i686 |
| 24 | + - Windows x86_64 |
| 25 | + - Windows x86_64-v3 |
| 26 | + # - Linux arm Hardware Float |
| 27 | + # - Linux armv7 Hardware Float |
| 28 | + # - Linux aarch64 |
| 29 | + # - Linux i686 |
| 30 | + - Linux x86_64 |
| 31 | + - Linux x86_64-v3 |
| 32 | + - macOS aarch64 |
| 33 | + - macOS x86_64 |
| 34 | + - macOS x86_64-v3 |
| 35 | + |
| 36 | + include: |
| 37 | + - label: Windows aarch64 |
| 38 | + target: aarch64-pc-windows-msvc |
| 39 | + os: windows-latest |
| 40 | + cross: skip |
| 41 | + install_target: true |
| 42 | + |
| 43 | + - label: Windows i686 |
| 44 | + target: i686-pc-windows-msvc |
| 45 | + os: windows-latest |
| 46 | + cross: skip |
| 47 | + install_target: true |
| 48 | + |
| 49 | + - label: Windows x86_64 |
| 50 | + target: x86_64-pc-windows-msvc |
| 51 | + os: windows-latest |
| 52 | + features: auto-splitting |
| 53 | + cross: skip |
| 54 | + |
| 55 | + - label: Windows x86_64-v3 |
| 56 | + target: x86_64-pc-windows-msvc |
| 57 | + target_rename: x86_64_v3-pc-windows-msvc |
| 58 | + rust_flags: -C target-cpu=x86-64-v3 |
| 59 | + os: windows-latest |
| 60 | + features: auto-splitting |
| 61 | + cross: skip |
| 62 | + |
| 63 | + # - label: Linux arm Hardware Float |
| 64 | + # target: arm-unknown-linux-gnueabihf |
| 65 | + # os: ubuntu-latest |
| 66 | + |
| 67 | + # - label: Linux armv7 Hardware Float |
| 68 | + # target: armv7-unknown-linux-gnueabihf |
| 69 | + # os: ubuntu-latest |
| 70 | + |
| 71 | + # - label: Linux aarch64 |
| 72 | + # target: aarch64-unknown-linux-gnu |
| 73 | + # os: ubuntu-latest |
| 74 | + # features: auto-splitting |
| 75 | + |
| 76 | + # - label: Linux i686 |
| 77 | + # target: i686-unknown-linux-gnu |
| 78 | + # os: ubuntu-22.04 |
| 79 | + # apt_arch: i386 |
| 80 | + # cross: skip |
| 81 | + # install_target: true |
| 82 | + |
| 83 | + - label: Linux x86_64 |
| 84 | + target: x86_64-unknown-linux-gnu |
| 85 | + os: ubuntu-22.04 |
| 86 | + apt_arch: amd64 |
| 87 | + features: auto-splitting |
| 88 | + cross: skip |
| 89 | + |
| 90 | + - label: Linux x86_64-v3 |
| 91 | + target: x86_64-unknown-linux-gnu |
| 92 | + target_rename: x86_64_v3-unknown-linux-gnu |
| 93 | + rust_flags: -C target-cpu=x86-64-v3 |
| 94 | + os: ubuntu-22.04 |
| 95 | + apt_arch: amd64 |
| 96 | + features: auto-splitting |
| 97 | + cross: skip |
| 98 | + |
| 99 | + - label: macOS aarch64 |
| 100 | + target: aarch64-apple-darwin |
| 101 | + os: macOS-latest |
| 102 | + features: auto-splitting |
| 103 | + cross: skip |
| 104 | + install_target: true |
| 105 | + |
| 106 | + - label: macOS x86_64 |
| 107 | + target: x86_64-apple-darwin |
| 108 | + os: macOS-latest |
| 109 | + features: auto-splitting |
| 110 | + cross: skip |
| 111 | + |
| 112 | + - label: macOS x86_64-v3 |
| 113 | + target: x86_64-apple-darwin |
| 114 | + target_rename: x86_64_v3-apple-darwin |
| 115 | + rust_flags: -C target-cpu=x86-64-v3 |
| 116 | + os: macOS-latest |
| 117 | + features: auto-splitting |
| 118 | + cross: skip |
| 119 | + |
| 120 | + steps: |
| 121 | + - name: Checkout Commit |
| 122 | + uses: actions/checkout@v3 |
| 123 | + |
| 124 | + - name: Install Rust |
| 125 | + uses: hecrj/setup-rust-action@v1 |
| 126 | + with: |
| 127 | + rust-version: ${{ matrix.toolchain || 'stable' }} |
| 128 | + |
| 129 | + - name: Install Target |
| 130 | + if: matrix.install_target != '' |
| 131 | + run: rustup target add ${{ matrix.target }} |
| 132 | + |
| 133 | + - name: Download cross |
| 134 | + if: matrix.cross == '' |
| 135 | + |
| 136 | + with: |
| 137 | + repository: "cross-rs/cross" |
| 138 | + latest: true |
| 139 | + fileName: "cross-x86_64-unknown-linux-gnu.tar.gz" |
| 140 | + out-file-path: "/home/runner/.cargo/bin" |
| 141 | + |
| 142 | + - name: Install cross |
| 143 | + if: matrix.cross == '' |
| 144 | + run: | |
| 145 | + cd ~/.cargo/bin |
| 146 | + tar -xzf cross-x86_64-unknown-linux-gnu.tar.gz |
| 147 | +
|
| 148 | + - name: Install apt packages |
| 149 | + if: matrix.cross == 'skip' && startsWith(matrix.os, 'ubuntu-') |
| 150 | + run: | |
| 151 | + sudo dpkg --add-architecture ${{ matrix.apt_arch }} |
| 152 | + sudo apt-get update |
| 153 | + sudo apt-get install --assume-yes libgtk-3-dev:${{ matrix.apt_arch }} |
| 154 | +
|
| 155 | + - name: Build |
| 156 | + run: bash .github/workflows/build.sh |
| 157 | + env: |
| 158 | + TARGET: ${{ matrix.target }} |
| 159 | + SKIP_CROSS: ${{ matrix.cross }} |
| 160 | + IS_DEPLOY: ${{ startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta'))) }} |
| 161 | + FEATURES: ${{ matrix.features }} |
| 162 | + RUSTFLAGS: ${{ matrix.rust_flags }} |
| 163 | + |
| 164 | + - name: Prepare Release |
| 165 | + if: startsWith(github.ref, 'refs/tags/') && matrix.release == '' |
| 166 | + run: bash .github/workflows/before_deploy.sh |
| 167 | + env: |
| 168 | + OS_NAME: ${{ matrix.os }} |
| 169 | + TARGET: ${{ matrix.target }} |
| 170 | + RELEASE_TARGET: ${{ matrix.target_rename || matrix.target }} |
| 171 | + |
| 172 | + - name: Release |
| 173 | + if: startsWith(github.ref, 'refs/tags/') && matrix.release == '' |
| 174 | + uses: softprops/action-gh-release@v1 |
| 175 | + with: |
| 176 | + files: livesplit-one-*.* |
| 177 | + env: |
| 178 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 179 | + |
| 180 | + clippy: |
| 181 | + runs-on: windows-latest |
| 182 | + steps: |
| 183 | + - name: Checkout Commit |
| 184 | + uses: actions/checkout@v3 |
| 185 | + |
| 186 | + - name: Install Rust |
| 187 | + uses: hecrj/setup-rust-action@v1 |
| 188 | + with: |
| 189 | + components: clippy |
| 190 | + |
| 191 | + - name: Run Clippy |
| 192 | + run: cargo clippy --all-features |
| 193 | + |
| 194 | + format: |
| 195 | + runs-on: ubuntu-latest |
| 196 | + steps: |
| 197 | + - name: Checkout Commit |
| 198 | + uses: actions/checkout@v3 |
| 199 | + |
| 200 | + - name: Install Rust |
| 201 | + uses: hecrj/setup-rust-action@v1 |
| 202 | + with: |
| 203 | + components: rustfmt |
| 204 | + |
| 205 | + - name: Run cargo fmt |
| 206 | + run: cargo fmt -- --check || true |
0 commit comments