name: semantic_release

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
        with:
          ref: master
      - name: Set up Python 3.7
        uses: actions/setup-python@v1
        with:
          python-version: 3.7
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install python-semantic-release pipenv
          make init
      - name: Make documentation
        run: |
          make docs
      - name: Setup Git
        run: |
          git config --global user.name "semantic-release"
          git config --global user.email "semantic-release@GitHub"
      - name: Publish with semantic-release
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          PYPI_PASSWORD: ${{ secrets.TESLA_PYPY_TOKEN }}
          PYPI_USERNAME: __token__
        run: |
          DEBUG='*' semantic-release publish
      - name: Push changes to dev
        uses: ad-m/github-push-action@master
        with:
         github_token: ${{ secrets.GITHUB_TOKEN }}
         branch: dev
