name: Release

on:
  push:
    tags:
      - 'v*'

jobs:
  check:
    name: Check
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v2
      - name: Cargo check
        uses: actions-rs/cargo@v1
        with:
          command: check

  release:
    name: Cargo publish
    runs-on: ubuntu-latest
    needs: check
    steps:
      - uses: actions/checkout@v1
      - run: cargo login ${CRATES_IO_TOKEN}
        env:
          CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
      - name: Cargo puhlish database-tree
        run: |
          cd database-tree
          cargo publish
      - run: sleep 2
      - run: cargo publish
        if: ${{ always() }}
