limitless-cli 1.0.0

A beginner-friendly environment diagnostic tool
Documentation
name: CI/CD

on:
  push:
    branches: [main]
  pull_request:

jobs:
  test:
    name: Test & lint (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    steps:
      - uses: actions/checkout@v4

      # .cargo/config.toml pins the Windows-GNU target + mingw gcc for local
      # Windows dev. On non-Windows runners it must be removed so builds use
      # the native toolchain.
      - name: Neutralize local Windows-GNU config (non-Windows)
        if: runner.os != 'Windows'
        run: rm -f .cargo/config.toml
        shell: bash

      - name: Set up MSYS2 / mingw64 (Windows)
        if: runner.os == 'Windows'
        uses: msys2/setup-msys2@v2
        with:
          update: true
          install: mingw-w64-x86_64-gcc

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ runner.os == 'Windows' && 'x86_64-pc-windows-gnu' || '' }}

      - name: Run tests
        run: cargo test --all-targets

      - name: Lint
        run: cargo clippy --all-targets -- -D warnings

  publish:
    name: Publish to crates.io
    needs: test
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Neutralize local Windows-GNU config
        run: rm -f .cargo/config.toml
        shell: bash

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Publish
        run: cargo publish

  release:
    name: Release binary (${{ matrix.os }})
    needs: test
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            pattern: target/release/limit
          - os: macos-latest
            pattern: target/release/limit
          - os: windows-latest
            pattern: target/release/limit.exe
    steps:
      - uses: actions/checkout@v4

      - name: Neutralize local Windows-GNU config (non-Windows)
        if: runner.os != 'Windows'
        run: rm -f .cargo/config.toml
        shell: bash

      - name: Set up MSYS2 / mingw64 (Windows)
        if: runner.os == 'Windows'
        uses: msys2/setup-msys2@v2
        with:
          update: true
          install: mingw-w64-x86_64-gcc

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ runner.os == 'Windows' && 'x86_64-pc-windows-gnu' || '' }}

      - name: Build release
        run: cargo build --release

      - name: Upload binary to GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: ${{ matrix.pattern }}