name: Publish the release package to PyPI

on:
  release:
    types:
      - published

jobs:

  publish:
    name: Publish the release package to PyPI
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.8.3
      - name: Install Python dependencies
        run: python -m pip install --requirement publish-requirements.txt
      - name: Build the package
        run: python setup.py bdist_wheel
      - name: Publish the package to PyPI
        run: twine upload --skip-existing --verbose dist/*
        env:
          TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
          TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}

name: Publish the release package to PyPI

on:
  release:
    types:
      - published

jobs:

  publish:
    name: Publish the release package to PyPI
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repository
        uses: actions/checkout@v2
      - name: Log in to the GitHub registry
        run: docker login --password "${{ github.token }}" --username "${{ github.actor }}" docker.pkg.github.com
      - name: Build the package
        run: docker-compose run -T py-build
      - name: Publish the package to PyPI
        run: docker-compose run -T twine-upload
        env:
          TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
          TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
      - name: Get file names
        id: files
        run: |
          echo "::set-output name=sdist::$(cd dist && ls *.gz)"
          echo "::set-output name=wheel::$(cd dist && ls *.whl)"
      - name: Upload sdist to release
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          asset_content_type: application/octet-stream
          asset_path: ${{ github.workspace }}/dist/${{ steps.files.outputs.sdist }}
          asset_name: ${{ steps.files.outputs.sdist }}
          upload_url: ${{ github.event.release.upload_url }}
      - name: Upload wheel to release
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ github.token }}
        with:
          asset_content_type: application/octet-stream
          asset_path: ${{ github.workspace }}/dist/${{ steps.files.outputs.wheel }}
          asset_name: ${{ steps.files.outputs.wheel }}
          upload_url: ${{ github.event.release.upload_url }}

Update workflow for publishing a release
Update workflow for publishing a release