
name: Build and Deploy
on:
  push:
    branches:
      - master
    tags:
      - '*'
jobs:
  build-and-publish-python-module:
    name: Build and publish python module to pypi
    runs-on: ubuntu-18.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup python 3.6
        uses: actions/setup-python@v1
        with:
          python-version: 3.6
      - name: Add wheel dependency
        run: pip install wheel
      - name: Generate dist
        run: python setup.py sdist bdist_wheel
      - name: Publish to PyPI
        if: startsWith(github.event.ref, 'refs/tags')
        uses: pypa/gh-action-pypi-publish@master
        with:
          user: __token__
          password: ${{ secrets.pypi_password }}
  build-and-publish-docker-image:
    name: Build and publish docker image
    runs-on: ubuntu-18.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Login with docker
        run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
      - name: Publish to Registry for latest
        if: success()
        run: make build-push-image-latest
      - name: Publish to Registry for version
        if: startsWith(github.event.ref, 'refs/tags')
        run: make build-push-image-version
