name: publish
on:
  release:
    types: [published]

jobs:
  publish:
    name: Publish 🚀
    runs-on: ubuntu-latest
    env:
      VERSION: null

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 🐍
      uses: actions/setup-python@v2
      with:
        python-version: 3.x
    - name: Install dependencies ⚙️
      run: |
        python -m pip install --upgrade pip
        pip install build
    - name: Get version
      run: |
        cat setup.cfg | grep "version = " | awk '{print "VERSION="$(NF)}' >> $GITHUB_ENV
    - name: Build a binary wheel and a source tarball 🚧
      run: python -m build --sdist --wheel --outdir dist/ .
    - name: Validate release tag
      run: |
        if [ "${GITHUB_REF#refs/tags/}" != "${VERSION}" ]; then exit 1; fi
    - name: Publish to Test PyPI 📦
      if: contains(env.VERSION, 'a')
      uses: pypa/gh-action-pypi-publish@v1.4.2
      with:
        user: __token__
        password: ${{ secrets.TEST_PYPI_API_TOKEN }}
        repository_url: https://test.pypi.org/legacy/
    - name: Publish to PyPI 📦
      if: |
        !contains(env.VERSION, 'a')
      uses: pypa/gh-action-pypi-publish@v1.4.2
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}

name: publish
on:
  release:
    types: [published]
    branches:
      - master

jobs:
  publish:
    name: Publish 🚀
    runs-on: ubuntu-latest
    env:
      VERSION: null

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 🐍
      uses: actions/setup-python@v2
      with:
        python-version: 3.x
    - name: Install dependencies ⚙️
      run: |
        python -m pip install --upgrade pip
        pip install build
    - name: Get version
      run: |
        cat setup.cfg | grep "version = " | awk '{print "VERSION="$(NF)}' >> $GITHUB_ENV
    - name: Build a binary wheel and a source tarball 🚧
      run: python -m build --sdist --wheel --outdir dist/ .
    - name: Validate release tag
      run: |
        if [ "${GITHUB_REF#refs/tags/}" != "${VERSION}" ]; then exit 1; fi
    - name: Publish to Test PyPI 📦
      if: contains(env.VERSION, 'a')
      uses: pypa/gh-action-pypi-publish@v1.4.2
      with:
        user: __token__
        password: ${{ secrets.TEST_PYPI_API_TOKEN }}
        repository_url: https://test.pypi.org/legacy/
    - name: Publish to PyPI 📦
      if: |
        !contains(env.VERSION, 'a')
      uses: pypa/gh-action-pypi-publish@v1.4.2
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}

Update github action for publishing release to only trigger on master branch
Update github action for publishing release to only trigger on master branch
