Last active
November 26, 2019 02:52
-
-
Save haranjackson/9cfcc358c56348684a787b64ab3e964d to your computer and use it in GitHub Desktop.
GitHub workflow for deploying a Python package to PyPI. The package can contain a CMake build step. Wheels are built for Linux, MacOS, and Windows, for Python versions 3.6-3.8. You must first create a GitHub secret called 'pypi_password' containing your PyPI API key.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: [push] | |
jobs: | |
nonlinux-build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [macOS-latest, windows-latest] | |
python-version: [3.6, 3.7, 3.8] | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.os }} ${{ matrix.python-version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Setup Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: x64 | |
- name: Install Dependencies | |
run: | | |
python -m pip install setuptools wheel scikit-build | |
python setup.py sdist bdist_wheel | |
- name: Publish to PyPI | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | |
run: | | |
python -m pip install twine | |
python -m twine upload --skip-existing -u __token__ -p ${{ secrets.pypi_password }} dist/* | |
linux-build: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: [cp36-cp36m, cp37-cp37m, cp38-cp38] | |
runs-on: ubuntu-latest | |
name: manylinux ${{ matrix.python-version }} | |
container: quay.io/pypa/manylinux2010_x86_64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Install Dependencies | |
run: | | |
/opt/python/${{ matrix.python-version }}/bin/pip install setuptools wheel scikit-build cmake | |
export PATH="/opt/python/${{ matrix.python-version }}/bin:$PATH" | |
/opt/python/${{ matrix.python-version }}/bin/python setup.py bdist_wheel | |
auditwheel repair dist/*whl -w dist_audited | |
- name: Publish to PyPI | |
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | |
run: | | |
/opt/python/${{ matrix.python-version }}/bin/pip install twine | |
/opt/python/${{ matrix.python-version }}/bin/python -m twine upload --skip-existing -u __token__ -p ${{ secrets.pypi_password }} dist_audited/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment