precord 0.7.13

Command line tool for recording process or system performance data
name: Rust

on:
  push:
    branches: [ master ]
    tags:
      - '*'
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Check ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, windows-latest, ubuntu-latest]
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - uses: hustcer/setup-nu@v3
        with:
          version: '0.95.0'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: caching
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Check
        if: "!startsWith(github.ref, 'refs/tags/')"
        run: |
          nu -n -c "overlay use action.nu; check"

      - name: Build macOS
        if: "startsWith(github.ref, 'refs/tags/') && matrix.os == 'macos-latest'"
        env:
          MACOSX_DEPLOYMENT_TARGET: "10.11"
        run : |
          nu -n -c "overlay use action.nu; build --version ${{ github.ref_name }} aarch64-apple-darwin x86_64-apple-darwin"

      - name: Build Windows
        if: "startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest'"
        env:
          RUSTFLAGS: "-C target-feature=+crt-static"
        run : |
          nu -n -c "overlay use action.nu; build --version ${{ github.ref_name }} x86_64-pc-windows-msvc"

      - name: Build Linux
        if: "startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest'"
        run: |
          nu -n -c "overlay use action.nu; build --version ${{ github.ref_name }} x86_64-unknown-linux-gnu"

      - name: Release
        if: "startsWith(github.ref, 'refs/tags/')"
        uses: softprops/action-gh-release@v1
        with:
          files: |
            target/*.tar.gz
            target/*.zip
            target/*.exe