Skip to content

Add GitHub Actions workflow to build and publish release zips #1

Add GitHub Actions workflow to build and publish release zips

Add GitHub Actions workflow to build and publish release zips #1

Workflow file for this run

name: Build and Release
on:
push:
branches: [master]
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: .exe
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: ""
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
ext: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: netmon
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build netmon
working-directory: netmon
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Windows)
if: matrix.os == 'windows-latest'
run: Compress-Archive -Path "netmon/target/${{ matrix.target }}/release/netmon.exe" -DestinationPath "netmon-${{ matrix.target }}.zip"
- name: Package (Linux)
if: matrix.os != 'windows-latest'
run: zip "netmon-${{ matrix.target }}.zip" "netmon/target/${{ matrix.target }}/release/netmon"
- uses: actions/upload-artifact@v4
with:
name: netmon-${{ matrix.target }}
path: netmon-${{ matrix.target }}.zip
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish latest release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release delete latest --yes --cleanup-tag 2>/dev/null || true
gh release create latest artifacts/*.zip \
--prerelease \
--title "Latest Builds" \
--notes "Built from commit \`${{ github.sha }}\` on \`${{ github.ref_name }}\`."