name: CrackMapExec Tests & Build

on:
  workflow_dispatch:
    branches: [ main ]
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    name: CrackMapExec Tests on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      max-parallel: 4
      matrix:
        os: [ubuntu-latest, macOS-latest, windows-latest]
        python-version: ["3.8", "3.9", "3.10", "3.11"]
    steps:
    - uses: actions/checkout@v3
    - name: CrackMapExec tests on ${{ matrix.os }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}
    - name: Build binaries with Shiv
      run: |
        pip install shiv
        python build_collector.py
    - name: Upload cme binary
      uses: actions/upload-artifact@master
      with:
        name: cme-${{ matrix.os }}-${{ matrix.python-version }}
        path: bin/cme
    - name: Upload cmedb binary
      uses: actions/upload-artifact@master
      with:
        name: cmedb-${{ matrix.os }}-${{ matrix.python-version }}
        path: bin/cmedb
