name: Check
on:
push:
branches: ["*"]
tags-ignore: ["v*"]
paths:
- ".github/workflows/*.yml"
- "Cargo.toml"
- "Cargo.lock"
- "src/**"
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check:
runs-on: macos-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --check
- name: Clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build --release --locked
- name: Compute artifact name
id: artifact
if: github.event_name != 'pull_request'
run: |
REF="${GITHUB_REF_NAME:-${GITHUB_REF##*/}}"
SAFE_REF=$(echo "$REF" | tr '/\\' '-')
echo "safe_ref=$SAFE_REF" >> "$GITHUB_OUTPUT"
- name: Create artifact
if: github.event_name != 'pull_request'
run: |
SAFE_REF="${{ steps.artifact.outputs.safe_ref }}"
tar -czvf macnetmon-${SAFE_REF}.tar.gz -C target/release macnetmon -C ${{ github.workspace }} README.md LICENSE
- name: Upload artifact
uses: actions/upload-artifact@v6
if: github.event_name != 'pull_request'
with:
name: macnetmon-${{ steps.artifact.outputs.safe_ref }}
path: macnetmon-${{ steps.artifact.outputs.safe_ref }}.tar.gz
retention-days: 7