name: CI

on: [push]

env:
  CARGO_TERM_COLOR: always

jobs:
  ci:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Clippy
        run: cargo clippy --tests --workspace
      - name: Build
        run: cargo build --verbose
      - name: Run tests
        run: cargo test --verbose
      - name: Publish (dry run)
        run: cargo publish --dry-run
        if: github.ref != 'refs/heads/master'
      - name: Publish on crates.io
        run: |
          cargo login ${{ secrets.CRATES_IO_TOKEN }}
          cargo publish
        if: github.ref == 'refs/heads/master'
