name: Main
on: push
jobs:
  test_publish:
    name: Test and publish
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: make setup
      - name: Run tests
        run: make test
      - name: Publish (dry run)
        run: cargo publish --dry-run
      - name: Publish
        if: startsWith(github.ref, 'refs/tags/') # Only publish for tagged commits.
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: make publish
