name: Build and Publish

on:
  push:
    branches:
      - main

jobs:
  publish:
    name: Publish
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v1

      - name: Install latest rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          default: true
          override: true

      - name: Build and Test
        run: |
          cargo build --release
          cargo test

      - name: Sign in to crates.io
        run: cargo login ${{ secrets.CARGO_TOKEN }}

      - name: Publish
        run: cargo publish
