From 3601d4f0fe713550e9be2622ca1289c013ba6934 Mon Sep 17 00:00:00 2001 From: Alexis Arnaudon Date: Sat, 30 Jan 2021 22:35:58 +0100 Subject: [PATCH] Update python-publish.yml --- .github/workflows/python-publish.yml | 107 ++++++++++++++++++++------- 1 file changed, 81 insertions(+), 26 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index a5a4dd4..fa1b3c9 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,11 +1,9 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package +name: Publish sdist and wheels macos-manylinux on: - release: - types: [created] + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' env: CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 @@ -16,28 +14,85 @@ env: CIBW_SKIP: 'cp35-* cp39-* *-manylinux_i686' CIBW_BEFORE_TEST: pip install nose mock h5py numpy CIBW_TEST_COMMAND: nosetests -s -v -P {project}/tests - + jobs: - deploy: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04, macos-latest] + + steps: + - uses: actions/checkout@v2 + with: + submodules: 'true' + + - uses: actions/setup-python@v2 + name: Install Python + with: + python-version: '3.7' + - name: Install cibuildwheel + run: | + python -m pip install cibuildwheel==1.6.4 pybind11 + - name: Build wheels on Linux + if: runner.os == 'Linux' + env: + CIBW_BEFORE_BUILD: 'yum update -y' + run: | + python -m cibuildwheel --output-dir dist + - name: Build wheels Mac OS + if: runner.os == 'macOS' + env: + CIBW_BEFORE_BUILD: | + brew update + brew unlink gcc@8 gcc@9 + brew install cmake + run: | + python -m cibuildwheel --output-dir dist + - name: Store wheel as artifact + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + + build_sdist: + name: Build sdist runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.6 + uses: actions/setup-python@v2 + with: + python-version: 3.6 + - name: Build a source tarball + run: + python setup.py sdist + - name: Store sdist as artifact + uses: actions/upload-artifact@v2 + with: + name: dist + path: dist + upload_wheels: + runs-on: ubuntu-latest + needs: [build_wheels, build_sdist] + name: Upload wheels to PyPI steps: - - uses: actions/checkout@v2 - with: - submodules: 'true' - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine pybind11 - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + - name: Download artifacts produced during the build_wheels and build_sdist jobs + uses: actions/download-artifact@v2 + with: + name: dist + path: dist + + - name: Display structure of downloaded files + run: ls -R + working-directory: dist + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_PASSWORD }} + packages_dir: dist/