name: Publish to crates.io

on:
  push:
    tags: "v*"

jobs:
  publish_crate:
    name: Publish to crates.io
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - name: Setup rust toolchain
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: Publish to crates.io
        env:
          CARGO_TOKEN: ${{ secrets.CARGO_TOKEN }}
        run: |
          cargo publish --token $CARGO_TOKEN
