Move if-clause of PyPI upload to job level rather than action level, and specify to use only published releases

This commit is contained in:
Yannick Jadoul
2020-06-08 13:23:28 +02:00
parent eedc5c6b79
commit bb5aac3d69
2 changed files with 66 additions and 61 deletions
+11 -6
View File
@@ -1,6 +1,11 @@
name: Build and upload to PyPI name: Build and upload to PyPI
on: [push, pull_request, release] on:
- push
- pull_request
- release:
types:
- published
jobs: jobs:
build_wheels: build_wheels:
@@ -56,7 +61,11 @@ jobs:
upload_pypi: upload_pypi:
needs: [build_wheels, build_sdist] needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest 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 - uses: actions/download-artifact@v2
with: with:
name: artifact name: artifact
@@ -67,7 +76,3 @@ jobs:
user: __token__ user: __token__
password: ${{ secrets.pypi_password }} password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/ # 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'