|
| 1 | +name: Build and Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + include: |
| 16 | + - os: windows-latest |
| 17 | + target: x86_64-pc-windows-msvc |
| 18 | + ext: .exe |
| 19 | + - os: ubuntu-latest |
| 20 | + target: x86_64-unknown-linux-gnu |
| 21 | + ext: "" |
| 22 | + - os: ubuntu-latest |
| 23 | + target: aarch64-unknown-linux-gnu |
| 24 | + ext: "" |
| 25 | + |
| 26 | + runs-on: ${{ matrix.os }} |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - uses: dtolnay/rust-toolchain@stable |
| 32 | + with: |
| 33 | + targets: ${{ matrix.target }} |
| 34 | + |
| 35 | + - uses: Swatinem/rust-cache@v2 |
| 36 | + with: |
| 37 | + workspaces: netmon |
| 38 | + |
| 39 | + - name: Install cross-compilation tools |
| 40 | + if: matrix.target == 'aarch64-unknown-linux-gnu' |
| 41 | + run: sudo apt-get install -y gcc-aarch64-linux-gnu |
| 42 | + |
| 43 | + - name: Build netmon |
| 44 | + working-directory: netmon |
| 45 | + env: |
| 46 | + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc |
| 47 | + run: cargo build --release --target ${{ matrix.target }} |
| 48 | + |
| 49 | + - name: Package (Windows) |
| 50 | + if: matrix.os == 'windows-latest' |
| 51 | + run: Compress-Archive -Path "netmon/target/${{ matrix.target }}/release/netmon.exe" -DestinationPath "netmon-${{ matrix.target }}.zip" |
| 52 | + |
| 53 | + - name: Package (Linux) |
| 54 | + if: matrix.os != 'windows-latest' |
| 55 | + run: zip "netmon-${{ matrix.target }}.zip" "netmon/target/${{ matrix.target }}/release/netmon" |
| 56 | + |
| 57 | + - uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: netmon-${{ matrix.target }} |
| 60 | + path: netmon-${{ matrix.target }}.zip |
| 61 | + |
| 62 | + release: |
| 63 | + needs: build |
| 64 | + runs-on: ubuntu-latest |
| 65 | + |
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + path: artifacts |
| 72 | + merge-multiple: true |
| 73 | + |
| 74 | + - name: Publish latest release |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + run: | |
| 78 | + gh release delete latest --yes --cleanup-tag 2>/dev/null || true |
| 79 | + gh release create latest artifacts/*.zip \ |
| 80 | + --prerelease \ |
| 81 | + --title "Latest Builds" \ |
| 82 | + --notes "Built from commit \`${{ github.sha }}\` on \`${{ github.ref_name }}\`." |
0 commit comments