name: Release

on:
  release:
    types: [published]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.9'

    - name: Install Python dependencies
      run: |
        python -m pip install --upgrade pip
        pip install wheel twine

    - name: Verify tag is documented
      run: |
        CURRENT_TAG=${GITHUB_REF#refs/tags/}
        CURRENT_VERSION=$(head -n1 social_core/__init__.py | awk '{print $3}' | sed 's/[^0-9\.]//g')
        if [ "${CURRENT_VERSION}" != "${CURRENT_TAG}" ]; then
            echo "========================================================================"
            echo "Error: tag '${CURRENT_TAG}' and version '${CURRENT_VERSION}' don't match"
            echo "========================================================================"
            exit 1;
        fi

    - name: Build dist
      run: python setup.py sdist bdist_wheel --python-tag py3

    - name: Archive dist
      uses: actions/upload-artifact@v2
      with:
        name: dist
        path: |
          dist/*.tar.gz
          dist/*.whl

    - name: Verify long description rendering
      run: twine check dist/*

    - name: Publish
      env:
        TWINE_USERNAME: ${{ secrets.PYPI_USER }}
        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
      run: twine upload -r dist/*

name: Release

on:
  release:
    types: [published]

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.9'

    - name: Install Python dependencies
      run: |
        python -m pip install --upgrade pip
        pip install wheel twine

    - name: Verify tag is documented
      run: |
        CURRENT_TAG=${GITHUB_REF#refs/tags/}
        CURRENT_VERSION=$(head -n1 social_core/__init__.py | awk '{print $3}' | sed 's/[^0-9\.]//g')
        if [ "${CURRENT_VERSION}" != "${CURRENT_TAG}" ]; then
            echo "========================================================================"
            echo "Error: tag '${CURRENT_TAG}' and version '${CURRENT_VERSION}' don't match"
            echo "========================================================================"
            exit 1;
        fi

    - name: Build dist
      run: python setup.py sdist bdist_wheel --python-tag py3

    - name: Archive dist
      uses: actions/upload-artifact@v2
      with:
        name: dist
        path: |
          dist/*.tar.gz
          dist/*.whl

    - name: Verify long description rendering
      run: twine check dist/*

    - name: Publish
      env:
        PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
      run: |
        echo <<EOF > ./pypirc
        [distutils]
        index-servers =
          pypi

        [pypi]
        username = __token__
        password = ${PYPI_API_TOKEN}
        EOF
        twine upload -c ./pypirc -r dist/*
        rm -rf ./pypirc dist/

Switch pypi creds to token
Switch pypi creds to token
