name: Rust

on:
  push:
    branches:
      - main
      - dev
  pull_request:
    branches:
      - main
      - dev

env:
  CARGO_TERM_COLOR: always

jobs:
  build_debug:
    runs-on: ubuntu-20.04
    container: rust:buster
    if: github.ref == 'refs/heads/dev'
    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose
    - name: Upload binary
      uses: actions/upload-artifact@v3
      with:
        name: hattivatti
        path: target/debug/hattivatti

  build_release:
    runs-on: ubuntu-20.04
    container: rust:buster
    if: github.ref == 'refs/heads/main'
    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --release --verbose
    - name: Run tests
      run: cargo test --verbose
    - name: Upload binary
      uses: actions/upload-artifact@v2
      with:
        name: hattivatti
        path: target/release/hattivatti
        
