From bb5aac3d690c8ce2d552af4c800baa2b75cc41d2 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Mon, 8 Jun 2020 13:23:28 +0200 Subject: [PATCH] Move if-clause of PyPI upload to job level rather than action level, and specify to use only published releases --- examples/github-deploy.yml | 91 +++++++++++++++++++------------------ examples/github-minimal.yml | 36 +++++++-------- 2 files changed, 66 insertions(+), 61 deletions(-) diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 0aa4dfed..625c67bd 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -1,6 +1,11 @@ name: Build and upload to PyPI -on: [push, pull_request, release] +on: + - push + - pull_request + - release: + types: + - published jobs: build_wheels: @@ -11,63 +16,63 @@ jobs: os: [ubuntu-18.04, windows-latest, macos-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.7' + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.7' - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==1.4.2 + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==1.4.2 - - name: Install Visual C++ for Python 2.7 - if: startsWith(matrix.os, 'windows') - run: | - choco install vcpython27 -f -y + - name: Install Visual C++ for Python 2.7 + if: startsWith(matrix.os, 'windows') + run: | + choco install vcpython27 -f -y - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse + - name: Build wheels + run: | + python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl build_sdist: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.7' + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.7' - - name: Build sdist - run: python setup.py sdist + - name: Build sdist + run: python setup.py sdist - - uses: actions/upload-artifact@v2 - with: - path: dist/*.tar.gz + - uses: actions/upload-artifact@v2 + with: + path: dist/*.tar.gz upload_pypi: needs: [build_wheels, build_sdist] runs-on: ubuntu-latest + # upload to PyPI on every tag starting with 'v' + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') + # alternatively, to publish when a GitHub Release is created, use the following rule: + # if: github.event_name == 'release' && github.event.action == 'published' + steps: + - uses: actions/download-artifact@v2 + with: + name: artifact + path: dist - - uses: actions/download-artifact@v2 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_password }} - # To test: repository_url: https://test.pypi.org/legacy/ - # upload to PyPI on every tag starting with 'v' - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') - # alternatively, to publish when a GitHub Release is created, use the following rule: - # if: github.event_name == 'release' && github.event.action == 'published' + - uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} + # To test: repository_url: https://test.pypi.org/legacy/ diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 70977138..3b1795f2 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -11,26 +11,26 @@ jobs: os: [ubuntu-18.04, windows-latest, macos-latest] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.7' + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.7' - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==1.4.2 + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==1.4.2 - - name: Install Visual C++ for Python 2.7 - if: startsWith(matrix.os, 'windows') - run: | - choco install vcpython27 -f -y + - name: Install Visual C++ for Python 2.7 + if: startsWith(matrix.os, 'windows') + run: | + choco install vcpython27 -f -y - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse + - name: Build wheels + run: | + python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl + - uses: actions/upload-artifact@v2 + with: + path: ./wheelhouse/*.whl