name: CI
on:
    push:
        branches:
            - release
    pull_request:
        branches:
            - release

jobs:
    release:
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v2
              with:
                  fetch-depth: 0
            - name: Setup Python 3.9
              uses: actions/setup-python@v2
            - name: Install Poetry
              uses: snok/install-poetry@v1.1.2
              with:
                  version: 1.1.4
                  virtualenvs-create: true
                  virtualenvs-in-project: true
            - name: Setup cache for dependencies
              id: cached-poetry-dependencies
              uses: actions/cache@v2
              with:
                  path: .venv
                  key: venv-${{  runner.os }}-${{ hashFiles('**/poetry.lock') }}
            - name: Install dependencies
              if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
              run: poetry install
            - name: Release
              env:
                  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
              run: |
                  git config --global user.name "github-actions"
                  git config --global user.email "action@github.com"
                  poetry run semantic-release publish -v DEBUG -D commit_author="github-actions <action@github.com>"
