domlist 1.7.5

Collects stat infomation from virsh. Mainly for OpenStack admin.

name: Main

on:
  push:

permissions:
  actions: write
  checks: write
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build-test:
    name: Build and test (${{ matrix.os }})
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v3
      - uses: swatinem/rust-cache@v2
      - name: Build
        run: >
          cargo build
          --release
          --verbose    
        env:
          CARGO_TARGET_DIR: binaries/${{ matrix.os }}

      - name: Run tests (without coverage)
        if: matrix.os != 'ubuntu-latest'
        run: >
          cargo test
          --verbose

      - name: Run tests (with coverage)
        if: matrix.os == 'ubuntu-latest'
        run: >
          cargo install cargo-tarpaulin
          && cargo tarpaulin
          --verbose
          --out Xml
          --engine llvm
          --skip-clean
          
      - name: Upload coverage reports to Codecov
        if: matrix.os == 'ubuntu-latest'
        uses: codecov/codecov-action@v3
   
      - name: Push binaries
        run: |
          git pull        
          git config user.name github-actions
          git config user.email github-actions@github.com
          git add -f binaries/${{ matrix.os }}/release/domlist
          git commit -m 'uploading binaries'
          git push

  release-please:
    name: Execute release chores
    permissions:
      contents: write
      pull-requests: write
    runs-on: ubuntu-latest
    needs: build-test
    outputs:
      created: ${{ steps.release.outputs.release_created }}
    steps:
      - uses: google-github-actions/release-please-action@v3
        id: release
        with:
          release-type: rust
        env:
          GITHUB_TOKEN: ${{ secrets.GIHHAB }}

  publish:
    name: Publish to crates.io

    runs-on: ubuntu-latest
    needs: release-please
    # if: needs.release-please.outputs.created

    environment: crates.io

    steps:
      - uses: actions/checkout@v3
      - uses: swatinem/rust-cache@v2

      - name: Publish
      # https://doc.rust-lang.org/cargo/reference/config.html?highlight=CARGO_REGISTRY_TOKEN#credentials
        run: >
          cargo publish
          --verbose
          --locked
          --token ${{ secrets.CARGO_REGISTRY_TOKEN }}