name: publish

on:
  push:
    branches: [main]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Configure git user
        run: |
          git config user.name "GitHub Actions"
          git config user.email noreply@github.com

      - name: Install cargo-release
        uses: actions-rs/install@v0.1
        with:
          crate: cargo-release
          version: latest

      - name: Publish
        run: |
          cargo login ${{ secrets.CRATES_IO_TOKEN }}
          cargo release --no-confirm --no-push -x

      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          tags: true
          force: true
          branch: ${{ github.ref }}
          github_token: ${{ secrets.GITHUB_TOKEN }}
