|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: [ push, pull_request ] |
| 4 | + |
| 5 | +env: |
| 6 | + CARGO_BIN_NAME: dtk |
| 7 | + CARGO_TARGET_DIR: target |
| 8 | + |
| 9 | +jobs: |
| 10 | + check: |
| 11 | + name: Check |
| 12 | + runs-on: ubuntu-latest |
| 13 | + env: |
| 14 | + RUSTFLAGS: -D warnings |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v3 |
| 18 | + - name: Setup Rust toolchain |
| 19 | + uses: dtolnay/rust-toolchain@stable |
| 20 | + with: |
| 21 | + components: rustfmt, clippy |
| 22 | + - name: Cargo check |
| 23 | + run: cargo check --all-features |
| 24 | + - name: Cargo clippy |
| 25 | + run: cargo clippy --all-features |
| 26 | + |
| 27 | + deny: |
| 28 | + name: Deny |
| 29 | + runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + checks: |
| 33 | + - advisories |
| 34 | + - bans licenses sources |
| 35 | + # Prevent new advisories from failing CI |
| 36 | + continue-on-error: ${{ matrix.checks == 'advisories' }} |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + - uses: EmbarkStudios/cargo-deny-action@v1 |
| 40 | + with: |
| 41 | + command: check ${{ matrix.checks }} |
| 42 | + |
| 43 | + test: |
| 44 | + name: Test |
| 45 | + strategy: |
| 46 | + matrix: |
| 47 | + platform: [ ubuntu-latest, windows-latest, macos-latest ] |
| 48 | + fail-fast: false |
| 49 | + runs-on: ${{ matrix.platform }} |
| 50 | + steps: |
| 51 | + - name: Checkout |
| 52 | + uses: actions/checkout@v3 |
| 53 | + - name: Setup Rust toolchain |
| 54 | + uses: dtolnay/rust-toolchain@stable |
| 55 | + - name: Cargo test |
| 56 | + run: cargo test --release --all-features |
| 57 | + |
| 58 | + build: |
| 59 | + name: Build |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + include: |
| 63 | + - platform: ubuntu-latest |
| 64 | + target: x86_64-unknown-linux-gnu |
| 65 | + name: linux-x86_64 |
| 66 | + - platform: ubuntu-latest |
| 67 | + target: aarch64-unknown-linux-gnu |
| 68 | + name: linux-aarch64 |
| 69 | + packages: gcc-aarch64-linux-gnu |
| 70 | + - platform: ubuntu-latest |
| 71 | + target: armv7-unknown-linux-gnueabihf |
| 72 | + name: linux-armv7l |
| 73 | + packages: gcc-arm-linux-gnueabihf |
| 74 | + - platform: windows-latest |
| 75 | + target: x86_64-pc-windows-msvc |
| 76 | + name: windows-x86_64 |
| 77 | + - platform: windows-latest |
| 78 | + target: aarch64-pc-windows-msvc |
| 79 | + name: windows-arm64 |
| 80 | + - platform: macos-latest |
| 81 | + target: x86_64-apple-darwin |
| 82 | + name: macos-x86_64 |
| 83 | + - platform: macos-latest |
| 84 | + target: aarch64-apple-darwin |
| 85 | + name: macos-arm64 |
| 86 | + fail-fast: false |
| 87 | + runs-on: ${{ matrix.platform }} |
| 88 | + steps: |
| 89 | + - name: Checkout |
| 90 | + uses: actions/checkout@v3 |
| 91 | + - name: Install dependencies |
| 92 | + if: matrix.packages != '' |
| 93 | + run: sudo apt-get -y install ${{ matrix.packages }} |
| 94 | + - name: Setup Rust toolchain |
| 95 | + uses: dtolnay/rust-toolchain@stable |
| 96 | + with: |
| 97 | + targets: ${{ matrix.target }} |
| 98 | + - name: Cargo build |
| 99 | + run: cargo build --release --all-features --target ${{ matrix.target }} --bin ${{ env.CARGO_BIN_NAME }} |
| 100 | + - name: Upload artifacts |
| 101 | + uses: actions/upload-artifact@v3 |
| 102 | + with: |
| 103 | + name: ${{ matrix.name }} |
| 104 | + path: | |
| 105 | + ${{ env.CARGO_TARGET_DIR }}/release/${{ env.CARGO_BIN_NAME }} |
| 106 | + ${{ env.CARGO_TARGET_DIR }}/release/${{ env.CARGO_BIN_NAME }}.exe |
| 107 | + ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/release/${{ env.CARGO_BIN_NAME }} |
| 108 | + ${{ env.CARGO_TARGET_DIR }}/${{ matrix.target }}/release/${{ env.CARGO_BIN_NAME }}.exe |
| 109 | + if-no-files-found: error |
| 110 | + |
| 111 | + release: |
| 112 | + name: Release |
| 113 | + if: startsWith(github.ref, 'refs/tags/') |
| 114 | + runs-on: ubuntu-latest |
| 115 | + needs: [ build ] |
| 116 | + steps: |
| 117 | + - name: Download artifacts |
| 118 | + uses: actions/download-artifact@v3 |
| 119 | + with: |
| 120 | + path: artifacts |
| 121 | + - name: Rename artifacts |
| 122 | + working-directory: artifacts |
| 123 | + run: | |
| 124 | + mkdir ../out |
| 125 | + for i in */*/release/$CARGO_BIN_NAME*; do |
| 126 | + mv "$i" "../out/$(sed -E "s/([^/]+)\/[^/]+\/release\/($CARGO_BIN_NAME)/\2-\1/" <<< "$i")" |
| 127 | + done |
| 128 | + ls -R ../out |
| 129 | + - name: Release |
| 130 | + uses: softprops/action-gh-release@v1 |
| 131 | + with: |
| 132 | + files: out/* |
0 commit comments