diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 676f32cd..1aa34077 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,3 +1,11 @@ +# This workflow is triggered by a new release on GitHub and then uploads +# MulensModel package to PyPI. +# +# If the publish step finishes succesfully, the source distribution is +# guaranteed to be published. Binary distributions are published only if +# their respective build steps passes. If any binary distribution fails, +# package maintainers may manually debug, build, and publish without the +# automated workflow. name: Upload Python Package to PyPI on: @@ -5,8 +13,38 @@ on: types: [published] jobs: - publish: + build_binary_manylinux: + runs-on: ubuntu-latest + container: quay.io/pypa/manylinux_2_24_x86_64 + + strategy: + matrix: + python-version: + - cp37-cp37m + - cp38-cp38 + - cp39-cp39 + - cp310-cp310 + + steps: + - uses: actions/checkout@v2 + + - name: Build Python wheels + # Build linux wheels with the image then use auditwheel + # to convert to it a manylinux wheel. + env: + PYTHON_VERSION: ${{ matrix.python-version }} + run: | + /opt/python/$PYTHON_VERSION/bin/python -m build --wheel + find dist/ -type f -name *.whl | xargs -L 1 auditwheel repair --wheel-dir dist/ + + - uses: actions/upload-artifact@v2 + # Only upload manylinux wheels to artifact. + # Normal linux wheels is not allowed in PyPI + with: + name: dist + path: dist/*manylinux*.whl + build_source: runs-on: ubuntu-latest steps: @@ -15,7 +53,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: "3.9" + python-version: "3.10" - name: Install dependencies run: | @@ -25,6 +63,25 @@ jobs: - name: Build package run: python setup.py sdist + - uses: actions/upload-artifact@v2 + with: + name: dist + path: dist/*.tar.gz + + publish: + # Publish to PyPI and update GitHub release + # Here we require only the source build to start publishing + needs: [build_source] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/download-artifact@v2 + with: + name: dist + path: dist/ + - name: Publish package to PyPI # All files in dist/ are published uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index 374b58cb..8d91941b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=42", + "setuptools", "wheel" ] build-backend = "setuptools.build_meta"