From add792de30092a6c0b56e832e0b56d243d7bc3c0 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 1 Jun 2020 15:02:26 +0200 Subject: [PATCH 01/15] example: for GH Actions use action to publish to PyPI, instead of calling twine directly. --- examples/github-minimal.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 2b4e801d..dde844e3 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -35,3 +35,12 @@ jobs: with: name: wheels path: ./wheelhouse + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@master #see https://github.com/pypa/gh-action-pypi-publish for setup + with: + user: __token__ + password: ${{ secrets.pypi_password }} + repository_url: https://test.pypi.org/legacy/ #TODO rm this line to use the "real" pypi + packages_dir: ./wheelhouse/ + From ca49d86ed8229db2eeec64ae898a184bd03e2e23 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 1 Jun 2020 15:32:51 +0200 Subject: [PATCH 02/15] example: publish to PyPI only on release tag --- examples/github-minimal.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index dde844e3..5e7f6b3b 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -37,6 +37,7 @@ jobs: path: ./wheelhouse - name: Publish to PyPI + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master #see https://github.com/pypa/gh-action-pypi-publish for setup with: user: __token__ From 63f7a2ddc4458e1e57019c5ff9b8a9f4c768ee25 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 1 Jun 2020 16:01:29 +0200 Subject: [PATCH 03/15] examples: revert to minima GH example, add deploymet example showing pypi and GH release --- examples/github-deployment.yml | 47 ++++++++++++++++++++++++++++++++++ examples/github-minimal.yml | 10 -------- 2 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 examples/github-deployment.yml diff --git a/examples/github-deployment.yml b/examples/github-deployment.yml new file mode 100644 index 00000000..5e7f6b3b --- /dev/null +++ b/examples/github-deployment.yml @@ -0,0 +1,47 @@ +name: Build + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheel on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v1 + + - uses: actions/setup-python@v1 + name: Install Python + with: + python-version: '3.7' + + - 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: Build wheel + run: | + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v1 + with: + name: wheels + path: ./wheelhouse + + - name: Publish to PyPI + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master #see https://github.com/pypa/gh-action-pypi-publish for setup + with: + user: __token__ + password: ${{ secrets.pypi_password }} + repository_url: https://test.pypi.org/legacy/ #TODO rm this line to use the "real" pypi + packages_dir: ./wheelhouse/ + diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 5e7f6b3b..2b4e801d 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -35,13 +35,3 @@ jobs: with: name: wheels path: ./wheelhouse - - - name: Publish to PyPI - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master #see https://github.com/pypa/gh-action-pypi-publish for setup - with: - user: __token__ - password: ${{ secrets.pypi_password }} - repository_url: https://test.pypi.org/legacy/ #TODO rm this line to use the "real" pypi - packages_dir: ./wheelhouse/ - From dd3c87ece2ed81aa164eaf794753887b3ba576f2 Mon Sep 17 00:00:00 2001 From: Marek Otahal Date: Mon, 1 Jun 2020 16:04:44 +0200 Subject: [PATCH 04/15] example: small doc --- examples/github-deployment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/github-deployment.yml b/examples/github-deployment.yml index 5e7f6b3b..d3e1c422 100644 --- a/examples/github-deployment.yml +++ b/examples/github-deployment.yml @@ -1,4 +1,4 @@ -name: Build +name: GH Deploy on: [push, pull_request] @@ -36,7 +36,7 @@ jobs: name: wheels path: ./wheelhouse - - name: Publish to PyPI + - name: Publish to PyPI # (optional) automatically publish the whl to PyPI on a new tag/release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master #see https://github.com/pypa/gh-action-pypi-publish for setup with: From 66b392f4ee899dcafa41c667e2aa8c792731ae1d Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 2 Jun 2020 11:48:15 +0200 Subject: [PATCH 05/15] Implement @henriii's suggestion, adding a separate job on Linux to upload all artifacts at once --- examples/github-deploy-only.yml | 82 +++++++++++++++++++++++++++++++++ examples/github-deployment.yml | 47 ------------------- examples/github-minimal.yml | 4 +- 3 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 examples/github-deploy-only.yml delete mode 100644 examples/github-deployment.yml diff --git a/examples/github-deploy-only.yml b/examples/github-deploy-only.yml new file mode 100644 index 00000000..3ee37d20 --- /dev/null +++ b/examples/github-deploy-only.yml @@ -0,0 +1,82 @@ +name: Build and upload to PyPI + +on: [push, pull_request] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v1 + + - uses: actions/setup-python@v1 + name: Install Python + with: + python-version: '3.7' + + - 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: Build wheels + run: | + python -m cibuildwheel --output-dir wheelhouse + + - uses: actions/upload-artifact@v1 + with: + name: wheels + path: ./wheelhouse + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + + - uses: actions/setup-python@v1 + name: Install Python + with: + python-version: '3.7' + + - name: Build sdist + run: python setup.py sdist -d wheelhouse/ + + - uses: actions/upload-artifact@v2 + with: + path: wheelhouse/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Install dependencies + run: python -m pip install twine + + - uses: actions/download-artifact@v2 + with: + name: artifact + path: wheelhouse + + - run: twine check wheelhouse/* + + - uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} + packages_dir: ./wheelhouse/ + # To test: repository_url: https://test.pypi.org/legacy/ + if: github.event_name == 'release' && github.event.action == 'published' diff --git a/examples/github-deployment.yml b/examples/github-deployment.yml deleted file mode 100644 index d3e1c422..00000000 --- a/examples/github-deployment.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: GH Deploy - -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheel on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04, windows-latest, macos-latest] - - steps: - - uses: actions/checkout@v1 - - - uses: actions/setup-python@v1 - name: Install Python - with: - python-version: '3.7' - - - 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: Build wheel - run: | - python -m cibuildwheel --output-dir wheelhouse - - - uses: actions/upload-artifact@v1 - with: - name: wheels - path: ./wheelhouse - - - name: Publish to PyPI # (optional) automatically publish the whl to PyPI on a new tag/release - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master #see https://github.com/pypa/gh-action-pypi-publish for setup - with: - user: __token__ - password: ${{ secrets.pypi_password }} - repository_url: https://test.pypi.org/legacy/ #TODO rm this line to use the "real" pypi - packages_dir: ./wheelhouse/ - diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 2b4e801d..dca435d3 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build_wheels: - name: Build wheel on ${{ matrix.os }} + name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -27,7 +27,7 @@ jobs: run: | choco install vcpython27 -f -y - - name: Build wheel + - name: Build wheels run: | python -m cibuildwheel --output-dir wheelhouse From 562d81c6ea07b77186e810673817ac023fd9fc27 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 2 Jun 2020 12:03:06 +0200 Subject: [PATCH 06/15] Add links to the PyPI deployment examples to the docs --- docs/deliver-to-pypi.md | 2 +- docs/setup.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/deliver-to-pypi.md b/docs/deliver-to-pypi.md index 15d2317e..4d351f25 100644 --- a/docs/deliver-to-pypi.md +++ b/docs/deliver-to-pypi.md @@ -33,4 +33,4 @@ Obviously, manual steps are for chumps, so we can automate this a little by usin If you don't need much control over the release of a package, you can set up cibuildwheel to deliver the wheels straight to PyPI. This doesn't require anycloud storage to work - you just need to bump the version and tag it. -Check out [this example repo](https://github.com/joerick/cibuildwheel-autopypi-example) for instructions on how to set this up. +[`examples/travis-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy-only.yml) and [`examples/github-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy-only.yml) are example configurations that automatocially upload wheels to PyPI. Also check out [this example repo](https://github.com/joerick/cibuildwheel-autopypi-example) for more detailed instructions on how to set this up. diff --git a/docs/setup.md b/docs/setup.md index f8b201ed..1e29f94d 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -15,6 +15,8 @@ Commit this file, and push to Github - either to your default branch, or to a PR For more info on this file, check out the [docs](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions). +[`examples/github-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy-only.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI. + # Azure Pipelines [linux/mac/windows] {: #azure-pipelines} To build Linux, Mac, and Windows wheels on Azure Pipelines, create a `azure-pipelines.yml` file in your repo. @@ -46,6 +48,8 @@ Commit this file, enable building of your repo on Travis CI, and push. Then setup a deployment method by following the [Travis CI deployment docs](https://docs.travis-ci.com/user/deployment/), or see [Delivering to PyPI](deliver-to-pypi.md). For more info on `.travis.yml`, check out the [docs](https://docs.travis-ci.com/). +[`examples/travis-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy-only.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI. + # CircleCI [linux/mac] {: #circleci} To build Linux and Mac wheels on CircleCI, create a `.circleci/config.yml` file in your repo, From d7cffde00fbc7dff14078a4d870f5576cba0fd84 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 2 Jun 2020 15:07:06 +0200 Subject: [PATCH 07/15] Add 'release' to 'on' section in examples/github-deploy-only.yml --- examples/github-deploy-only.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/github-deploy-only.yml b/examples/github-deploy-only.yml index 3ee37d20..699bd6a7 100644 --- a/examples/github-deploy-only.yml +++ b/examples/github-deploy-only.yml @@ -1,6 +1,6 @@ name: Build and upload to PyPI -on: [push, pull_request] +on: [push, pull_request, release] jobs: build_wheels: From 896337cbb1b5c9f84360c303c5bf11065207c9b8 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 2 Jun 2020 15:23:15 +0200 Subject: [PATCH 08/15] Updating all GitHub actions version to actions/checkout@v2, actions/setup-python@v2, and actions/upload-artifact@v2 --- .github/workflows/test.yml | 4 ++-- examples/github-deploy-only.yml | 11 +++++------ examples/github-minimal.yml | 7 +++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c8ebd4e..54aeb357 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,8 +18,8 @@ jobs: os: [ubuntu-18.04, windows-latest, macos-latest] python_version: ['3.7'] steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 name: Install Python ${{ matrix.python_version }} with: python-version: ${{ matrix.python_version }} diff --git a/examples/github-deploy-only.yml b/examples/github-deploy-only.yml index 699bd6a7..4f0a430a 100644 --- a/examples/github-deploy-only.yml +++ b/examples/github-deploy-only.yml @@ -11,9 +11,9 @@ jobs: os: [ubuntu-18.04, windows-latest, macos-latest] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 name: Install Python with: python-version: '3.7' @@ -31,18 +31,17 @@ jobs: run: | python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v2 with: - name: wheels path: ./wheelhouse build_sdist: name: Build source distribution runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 name: Install Python with: python-version: '3.7' diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index dca435d3..fa00a6d8 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -11,9 +11,9 @@ jobs: os: [ubuntu-18.04, windows-latest, macos-latest] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 name: Install Python with: python-version: '3.7' @@ -31,7 +31,6 @@ jobs: run: | python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v1 + - uses: actions/upload-artifact@v2 with: - name: wheels path: ./wheelhouse From 9c3f44d086880965d63765921a1110311321dbdf Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 2 Jun 2020 17:07:18 +0200 Subject: [PATCH 09/15] Rename examples/*-deploy-only.yml to examples/*-deploy.yml, and keep sdist in dist/ in examples/github-deploy.yml --- docs/deliver-to-pypi.md | 2 +- docs/setup.md | 4 ++-- .../{github-deploy-only.yml => github-deploy.yml} | 11 +++++------ examples/github-minimal.yml | 2 +- ...travis-ci-deploy-only.yml => travis-ci-deploy.yml} | 0 5 files changed, 9 insertions(+), 10 deletions(-) rename examples/{github-deploy-only.yml => github-deploy.yml} (89%) rename examples/{travis-ci-deploy-only.yml => travis-ci-deploy.yml} (100%) diff --git a/docs/deliver-to-pypi.md b/docs/deliver-to-pypi.md index 4d351f25..35d36062 100644 --- a/docs/deliver-to-pypi.md +++ b/docs/deliver-to-pypi.md @@ -33,4 +33,4 @@ Obviously, manual steps are for chumps, so we can automate this a little by usin If you don't need much control over the release of a package, you can set up cibuildwheel to deliver the wheels straight to PyPI. This doesn't require anycloud storage to work - you just need to bump the version and tag it. -[`examples/travis-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy-only.yml) and [`examples/github-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy-only.yml) are example configurations that automatocially upload wheels to PyPI. Also check out [this example repo](https://github.com/joerick/cibuildwheel-autopypi-example) for more detailed instructions on how to set this up. +[`examples/travis-deploy.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy.yml) and [`examples/github-deploy.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy.yml) are example configurations that automatocially upload wheels to PyPI. Also check out [this example repo](https://github.com/joerick/cibuildwheel-autopypi-example) for more detailed instructions on how to set this up. diff --git a/docs/setup.md b/docs/setup.md index 1e29f94d..1ff2bc55 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -15,7 +15,7 @@ Commit this file, and push to Github - either to your default branch, or to a PR For more info on this file, check out the [docs](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions). -[`examples/github-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy-only.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI. +[`examples/github-deploy.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/github-deploy.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI. # Azure Pipelines [linux/mac/windows] {: #azure-pipelines} @@ -48,7 +48,7 @@ Commit this file, enable building of your repo on Travis CI, and push. Then setup a deployment method by following the [Travis CI deployment docs](https://docs.travis-ci.com/user/deployment/), or see [Delivering to PyPI](deliver-to-pypi.md). For more info on `.travis.yml`, check out the [docs](https://docs.travis-ci.com/). -[`examples/travis-deploy-only.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy-only.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI. +[`examples/travis-deploy.yml`](https://github.com/joerick/cibuildwheel/blob/master/examples/travis-deploy.yml) extends this minimal example with a demonstration of how to automatically upload the built wheels to PyPI. # CircleCI [linux/mac] {: #circleci} diff --git a/examples/github-deploy-only.yml b/examples/github-deploy.yml similarity index 89% rename from examples/github-deploy-only.yml rename to examples/github-deploy.yml index 4f0a430a..f54bd0c4 100644 --- a/examples/github-deploy-only.yml +++ b/examples/github-deploy.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/upload-artifact@v2 with: - path: ./wheelhouse + path: ./wheelhouse/*.whl build_sdist: name: Build source distribution @@ -47,11 +47,11 @@ jobs: python-version: '3.7' - name: Build sdist - run: python setup.py sdist -d wheelhouse/ + run: python setup.py sdist - uses: actions/upload-artifact@v2 with: - path: wheelhouse/*.tar.gz + path: dist/*.tar.gz upload_pypi: needs: [build_wheels, build_sdist] @@ -68,14 +68,13 @@ jobs: - uses: actions/download-artifact@v2 with: name: artifact - path: wheelhouse + path: dist - - run: twine check wheelhouse/* + - run: twine check dist/* - uses: pypa/gh-action-pypi-publish@master with: user: __token__ password: ${{ secrets.pypi_password }} - packages_dir: ./wheelhouse/ # To test: repository_url: https://test.pypi.org/legacy/ if: github.event_name == 'release' && github.event.action == 'published' diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index fa00a6d8..70977138 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -33,4 +33,4 @@ jobs: - uses: actions/upload-artifact@v2 with: - path: ./wheelhouse + path: ./wheelhouse/*.whl diff --git a/examples/travis-ci-deploy-only.yml b/examples/travis-ci-deploy.yml similarity index 100% rename from examples/travis-ci-deploy-only.yml rename to examples/travis-ci-deploy.yml From 4c3cbf702c9e371ff1bc93d68fb16242f498a8e6 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Tue, 2 Jun 2020 22:09:33 +0200 Subject: [PATCH 10/15] Update examples/github-deploy.yml to upload on tags, as alternative to GitHub releases Co-authored-by: Joe Rickerby --- examples/github-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index f54bd0c4..7370b6cd 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -77,4 +77,7 @@ jobs: user: __token__ password: ${{ secrets.pypi_password }} # To test: repository_url: https://test.pypi.org/legacy/ - if: github.event_name == 'release' && github.event.action == 'published' + # 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' From eedc5c6b79813a6e6a81caa12701b22dae3fd891 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Wed, 3 Jun 2020 19:01:01 +0200 Subject: [PATCH 11/15] Remove twine check from examples/github-deploy.yml as it's now integrated into the pypa/gh-action-pypi-publish action --- examples/github-deploy.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 7370b6cd..0aa4dfed 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -57,21 +57,11 @@ jobs: needs: [build_wheels, build_sdist] runs-on: ubuntu-latest - steps: - - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - - name: Install dependencies - run: python -m pip install twine - - uses: actions/download-artifact@v2 with: name: artifact path: dist - - run: twine check dist/* - - uses: pypa/gh-action-pypi-publish@master with: user: __token__ From bb5aac3d690c8ce2d552af4c800baa2b75cc41d2 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Mon, 8 Jun 2020 13:23:28 +0200 Subject: [PATCH 12/15] 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 From cc8dbbe8b31cfc58c2dfc0035ac2a571e7d8fb59 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Mon, 8 Jun 2020 15:50:38 +0200 Subject: [PATCH 13/15] Make deploy on published GitHub release optional in examples/github-deploy.yml --- examples/github-deploy.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 625c67bd..54c4c2bc 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -1,11 +1,11 @@ name: Build and upload to PyPI -on: - - push - - pull_request - - release: - types: - - published +on: [push, pull_request] +# alternatively, to publish when a (published) GitHub Release is created, use the following: +# on: +# release: +# types: +# - published jobs: build_wheels: From 57e6f0f56deb30c362e4aea35753645afd282c74 Mon Sep 17 00:00:00 2001 From: Yannick Jadoul Date: Wed, 10 Jun 2020 01:53:41 +0200 Subject: [PATCH 14/15] Replace "startsWith(matrix.os, 'windows')" by "runner.os == 'Windows'" in GitHub Actions configurations --- .github/workflows/test.yml | 2 +- examples/github-deploy.yml | 2 +- examples/github-minimal.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54aeb357..b2e28e08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: run: | python -m pip install -r requirements-dev.txt - name: Install Visual C++ for Python 2.7 - if: startsWith(matrix.os, 'windows') + if: runner.os == 'Windows' run: | choco install vcpython27 -f -y - name: Test cibuildwheel diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index 54c4c2bc..b3d3fc04 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -28,7 +28,7 @@ jobs: python -m pip install cibuildwheel==1.4.2 - name: Install Visual C++ for Python 2.7 - if: startsWith(matrix.os, 'windows') + if: runner.os == 'Windows' run: | choco install vcpython27 -f -y diff --git a/examples/github-minimal.yml b/examples/github-minimal.yml index 3b1795f2..8501cb84 100644 --- a/examples/github-minimal.yml +++ b/examples/github-minimal.yml @@ -23,7 +23,7 @@ jobs: python -m pip install cibuildwheel==1.4.2 - name: Install Visual C++ for Python 2.7 - if: startsWith(matrix.os, 'windows') + if: runner.os == 'Windows' run: | choco install vcpython27 -f -y From 58fc4185632dc932c44a47db20a81a83db1f8a20 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Wed, 10 Jun 2020 13:18:22 +0100 Subject: [PATCH 15/15] Update to add clarity to `on:` section --- examples/github-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/github-deploy.yml b/examples/github-deploy.yml index b3d3fc04..746c5847 100644 --- a/examples/github-deploy.yml +++ b/examples/github-deploy.yml @@ -1,8 +1,11 @@ name: Build and upload to PyPI +# Build on every branch push, tag push, and pull request change: on: [push, pull_request] -# alternatively, to publish when a (published) GitHub Release is created, use the following: +# Alternatively, to publish when a (published) GitHub Release is created, use the following: # on: +# push: +# pull_request: # release: # types: # - published