macnetmon 0.1.4

Network interface bandwidth monitor for macOS
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:
  msrv:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v7

      - name: Read MSRV
        id: msrv
        run: |
          MSRV=$(sed -n 's/^rust-version = "\(.*\)"/\1/p' Cargo.toml)
          test -n "$MSRV"
          echo "version=$MSRV" >> "$GITHUB_OUTPUT"

      - uses: dtolnay/rust-toolchain@master
        id: toolchain
        with:
          toolchain: ${{ steps.msrv.outputs.version }}

      - uses: Swatinem/rust-cache@v2

      - name: Check minimum supported Rust version
        run: cargo +${{ steps.toolchain.outputs.name }} check --all-targets --all-features --locked

  check:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v7

      - 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="${REF//\//-}"
          SAFE_REF="${SAFE_REF//\\/-}"
          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@v7
        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