|
1 | | -name: Cargo Build & Test |
| 1 | +name: Build, Test, and Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
| 4 | + workflow_dispatch: |
5 | 5 | pull_request: |
| 6 | + push: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
6 | 10 |
|
7 | | -env: |
| 11 | +env: |
8 | 12 | CARGO_TERM_COLOR: always |
9 | 13 |
|
10 | 14 | jobs: |
|
41 | 45 | - run: cargo clippy --tests -- --deny warnings |
42 | 46 | - run: cargo test --verbose |
43 | 47 |
|
| 48 | + release: |
| 49 | + name: Build Release Binaries and Upload Artifacts |
| 50 | + runs-on: ${{ matrix.os }} |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + include: |
| 55 | + - os: ubuntu-latest |
| 56 | + target: x86_64-unknown-linux-gnu |
| 57 | + use_cross: true |
| 58 | + ext: "" |
| 59 | + - os: ubuntu-latest |
| 60 | + target: aarch64-unknown-linux-gnu |
| 61 | + use_cross: true |
| 62 | + ext: "" |
| 63 | + - os: ubuntu-latest |
| 64 | + target: armv7-unknown-linux-gnueabihf |
| 65 | + use_cross: true |
| 66 | + ext: "" |
| 67 | + - os: macos-latest |
| 68 | + target: aarch64-apple-darwin |
| 69 | + use_cross: false |
| 70 | + ext: "" |
| 71 | + - os: macos-latest |
| 72 | + target: x86_64-apple-darwin |
| 73 | + use_cross: false |
| 74 | + ext: "" |
| 75 | + - os: windows-latest |
| 76 | + target: x86_64-pc-windows-msvc |
| 77 | + use_cross: false |
| 78 | + ext: ".exe" |
| 79 | + steps: |
| 80 | + - name: Check out source |
| 81 | + uses: actions/checkout@v4 |
| 82 | + |
| 83 | + - name: Install Rust toolchain |
| 84 | + uses: dtolnay/rust-toolchain@stable |
| 85 | + with: |
| 86 | + targets: ${{ matrix.target }} |
| 87 | + |
| 88 | + - name: Install cross |
| 89 | + if: matrix.use_cross |
| 90 | + run: cargo install cross |
| 91 | + |
| 92 | + - name: Build release binary with cross |
| 93 | + if: matrix.use_cross |
| 94 | + run: cross build --release --target ${{ matrix.target }} |
| 95 | + |
| 96 | + - name: Build release binary with cargo |
| 97 | + if: ${{ !matrix.use_cross }} |
| 98 | + run: cargo build --release --target ${{ matrix.target }} |
| 99 | + |
| 100 | + - name: Upload build as workflow artifact |
| 101 | + uses: actions/upload-artifact@v4 |
| 102 | + with: |
| 103 | + name: disktest-${{ matrix.target }}${{ matrix.ext }} |
| 104 | + path: target/${{ matrix.target }}/release/disktest${{ matrix.ext }} |
| 105 | + if-no-files-found: error |
| 106 | + |
| 107 | + - name: Rename artifact |
| 108 | + shell: bash |
| 109 | + run: mv target/${{ matrix.target }}/release/disktest${{ matrix.ext }} disktest-${{ matrix.target }}${{ matrix.ext }} |
| 110 | + |
| 111 | + - name: Attach artifacts to GitHub release |
| 112 | + if: startsWith(github.ref, 'refs/tags/') |
| 113 | + uses: softprops/action-gh-release@v2 |
| 114 | + with: |
| 115 | + files: disktest-${{ matrix.target }}${{ matrix.ext }} |
| 116 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 117 | + |
44 | 118 | # vim: ts=2 sw=2 expandtab |
0 commit comments