# Based on https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish to PyPI
on:
  push:
    tags:
      - '**'

jobs:
  build-n-publish:
    name: Build and publish
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master
      with:
        fetch-depth: 0

    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7

    - name: Install pypa/build
      run: >-
        python -m pip install build --user
    - name: Build a binary wheel and a source tarball
      run: >-
        python -m
        build
        --sdist
        --wheel
        --outdir dist/
        .

    - name: Verify tag is annotated
      if: startsWith(github.ref, 'refs/tags')
      run: >-
        test $(git for-each-ref --format='%(objecttype)' ${GITHUB_REF}) == tag
    - name: Publish distribution to PyPI
      if: startsWith(github.ref, 'refs/tags')
      uses: pypa/gh-action-pypi-publish@master
      with:
        password: ${{ secrets.PYPI_API_TOKEN }}

# Based on https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish to PyPI
on:
  push:
    tags:
      - '**'

jobs:
  build-n-publish:
    name: Build and publish
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
      with:
        fetch-depth: 0

    - name: Set up Python
      uses: actions/setup-python@v1
      with:
        python-version: 3.7

    - name: Install pypa/build
      run: >-
        python -m pip install build --user
    - name: Build a binary wheel and a source tarball
      run: >-
        python -m
        build
        --sdist
        --wheel
        --outdir dist/
        .

    - name: Verify tag is annotated
      if: startsWith(github.ref, 'refs/tags')
      run: >-
        test $(git for-each-ref --format='%(objecttype)' ${GITHUB_REF}) == tag
    - name: Publish distribution to PyPI
      if: startsWith(github.ref, 'refs/tags')
      uses: pypa/gh-action-pypi-publish@master
      with:
        password: ${{ secrets.PYPI_API_TOKEN }}

Use github checkout v1 to preseve tag annotation
Use github checkout v1 to preseve tag annotation

Ref https://github.com/actions/checkout/issues/290
