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:
+48
-43
@@ -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:
|
||||||
@@ -11,63 +16,63 @@ jobs:
|
|||||||
os: [ubuntu-18.04, windows-latest, macos-latest]
|
os: [ubuntu-18.04, windows-latest, macos-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
name: Install Python
|
name: Install Python
|
||||||
with:
|
with:
|
||||||
python-version: '3.7'
|
python-version: '3.7'
|
||||||
|
|
||||||
- name: Install cibuildwheel
|
- name: Install cibuildwheel
|
||||||
run: |
|
run: |
|
||||||
python -m pip install cibuildwheel==1.4.2
|
python -m pip install cibuildwheel==1.4.2
|
||||||
|
|
||||||
- name: Install Visual C++ for Python 2.7
|
- name: Install Visual C++ for Python 2.7
|
||||||
if: startsWith(matrix.os, 'windows')
|
if: startsWith(matrix.os, 'windows')
|
||||||
run: |
|
run: |
|
||||||
choco install vcpython27 -f -y
|
choco install vcpython27 -f -y
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
run: |
|
run: |
|
||||||
python -m cibuildwheel --output-dir wheelhouse
|
python -m cibuildwheel --output-dir wheelhouse
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: ./wheelhouse/*.whl
|
path: ./wheelhouse/*.whl
|
||||||
|
|
||||||
build_sdist:
|
build_sdist:
|
||||||
name: Build source distribution
|
name: Build source distribution
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
name: Install Python
|
name: Install Python
|
||||||
with:
|
with:
|
||||||
python-version: '3.7'
|
python-version: '3.7'
|
||||||
|
|
||||||
- name: Build sdist
|
- name: Build sdist
|
||||||
run: python setup.py sdist
|
run: python setup.py sdist
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: dist/*.tar.gz
|
path: dist/*.tar.gz
|
||||||
|
|
||||||
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
|
||||||
|
with:
|
||||||
|
name: artifact
|
||||||
|
path: dist
|
||||||
|
|
||||||
- uses: actions/download-artifact@v2
|
- uses: pypa/gh-action-pypi-publish@master
|
||||||
with:
|
with:
|
||||||
name: artifact
|
user: __token__
|
||||||
path: dist
|
password: ${{ secrets.pypi_password }}
|
||||||
|
# To test: repository_url: https://test.pypi.org/legacy/
|
||||||
- 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'
|
|
||||||
|
|||||||
+18
-18
@@ -11,26 +11,26 @@ jobs:
|
|||||||
os: [ubuntu-18.04, windows-latest, macos-latest]
|
os: [ubuntu-18.04, windows-latest, macos-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: actions/setup-python@v2
|
- uses: actions/setup-python@v2
|
||||||
name: Install Python
|
name: Install Python
|
||||||
with:
|
with:
|
||||||
python-version: '3.7'
|
python-version: '3.7'
|
||||||
|
|
||||||
- name: Install cibuildwheel
|
- name: Install cibuildwheel
|
||||||
run: |
|
run: |
|
||||||
python -m pip install cibuildwheel==1.4.2
|
python -m pip install cibuildwheel==1.4.2
|
||||||
|
|
||||||
- name: Install Visual C++ for Python 2.7
|
- name: Install Visual C++ for Python 2.7
|
||||||
if: startsWith(matrix.os, 'windows')
|
if: startsWith(matrix.os, 'windows')
|
||||||
run: |
|
run: |
|
||||||
choco install vcpython27 -f -y
|
choco install vcpython27 -f -y
|
||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
run: |
|
run: |
|
||||||
python -m cibuildwheel --output-dir wheelhouse
|
python -m cibuildwheel --output-dir wheelhouse
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
path: ./wheelhouse/*.whl
|
path: ./wheelhouse/*.whl
|
||||||
|
|||||||
Reference in New Issue
Block a user