on:
  push:
    tags:
      - "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10

name: Create and Publish Release

jobs:
  build:
    name: Create and Publish Release
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.9]
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install release dependencies
        run: |
          python -m pip install --upgrade pip
          pip install --upgrade setuptools wheel twine
      - name: Create GitHub release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          body: |
            Please see the root of the repository for the CHANGELOG.md
          draft: false
          prerelease: false
      - name: Build and publish to PyPI
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
        run: |
          python setup.py sdist bdist_wheel
          twine upload dist/*

on:
  push:
    tags:
      - "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10

name: Create and Publish Release

jobs:
  build:
    name: Create and Publish Release
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: [3.9]
    steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install release dependencies
        run: |
          python -m pip install --upgrade pip
          pip install --upgrade setuptools wheel twine
      - name: Get release notes
        id: release_notes
        run: |
          CHANGELOG=$(git tag -l --format='%(contents)' ${{ github.ref }})
          CHANGELOG="${CHANGELOG//'%'/'%25'}"
          CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
          CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
          echo "::set-output name=changelog::$CHANGELOG"
      - name: Create GitHub release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}
          body: ${{ steps.release_notes.outputs.changelog }}
          draft: false
          prerelease: false
      - name: Build and publish to PyPI
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
        run: |
          python setup.py sdist bdist_wheel
          twine upload dist/*

Use the annotated tag message for release body
Use the annotated tag message for release body
