214 lines
6.3 KiB
YAML
214 lines
6.3 KiB
YAML
name: Python Wheels
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "[0-9]+.[0-9]+.[0-9]+"
|
|
- "[0-9]+.[0-9]+.[0-9]+.post[0-9]+"
|
|
- "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+"
|
|
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
|
|
workflow_dispatch:
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: wheels-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash -eux {0}
|
|
|
|
jobs:
|
|
build_wheels:
|
|
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
|
|
runs-on: ${{ matrix.buildplat[0] }}
|
|
strategy:
|
|
# Ensure that a wheel builder finishes even if another fails
|
|
fail-fast: false
|
|
matrix:
|
|
# Github Actions doesn't support pairing matrix values together, let's improvise
|
|
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
|
|
buildplat:
|
|
- [ubuntu-20.04, manylinux_x86_64]
|
|
- [ubuntu-20.04, manylinux_aarch64]
|
|
- [ubuntu-20.04, manylinux_ppc64le]
|
|
- [ubuntu-20.04, manylinux_s390x]
|
|
- [ubuntu-20.04, manylinux_i686]
|
|
- [windows-2019, win_amd64]
|
|
- [windows-2019, win32]
|
|
python: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312"]
|
|
include:
|
|
- buildplat: [macos-11, macosx_*]
|
|
python: "cp37"
|
|
- buildplat: [macos-11, macosx_*]
|
|
python: "cp38"
|
|
- buildplat: [macos-11, macosx_*]
|
|
python: "cp39"
|
|
- buildplat: [macos-14, macosx_*]
|
|
python: "cp310"
|
|
- buildplat: [macos-14, macosx_*]
|
|
python: "cp311"
|
|
- buildplat: [macos-14, macosx_*]
|
|
python: "cp312"
|
|
|
|
steps:
|
|
- name: Checkout pymongo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up python version
|
|
run: |
|
|
export PYTHON_VERSION=$(sed 's/^cp3/3./' <<< ${{ matrix.python }} )
|
|
echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{env.PYTHON_VERSION}}
|
|
cache: 'pip'
|
|
cache-dependency-path: 'pyproject.toml'
|
|
allow-prereleases: true
|
|
|
|
- name: Set up QEMU
|
|
if: runner.os == 'Linux'
|
|
uses: docker/setup-qemu-action@v3
|
|
with:
|
|
platforms: all
|
|
|
|
- name: Install cibuildwheel
|
|
# Note: the default manylinux is manylinux2014
|
|
run: |
|
|
python -m pip install -U pip
|
|
python -m pip install "cibuildwheel>=2.4,<3"
|
|
|
|
- name: Build wheel
|
|
if: ${{ matrix.buildplat[0] != 'macos-14' }}
|
|
env:
|
|
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
|
|
MACOS_TEST_SKIP: "*arm64"
|
|
run: python -m cibuildwheel --output-dir wheelhouse
|
|
|
|
- name: Build wheel on M1
|
|
if: ${{ matrix.buildplat[0] == 'macos-14' }}
|
|
env:
|
|
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
|
|
run: python -m cibuildwheel --output-dir wheelhouse
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheel-${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
|
|
path: ./wheelhouse/*.whl
|
|
if-no-files-found: error
|
|
|
|
build_manylinux1_wheels:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
# Ensure that a wheel builder finishes even if another fails
|
|
fail-fast: false
|
|
matrix:
|
|
python: ["cp37", "cp38", "cp39"]
|
|
steps:
|
|
- name: Checkout pymongo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up python version
|
|
run: |
|
|
export PYTHON_VERSION=$(sed 's/^cp3/3./' <<< ${{ matrix.python }} )
|
|
echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{env.PYTHON_VERSION}}
|
|
cache: 'pip'
|
|
cache-dependency-path: 'pyproject.toml'
|
|
allow-prereleases: true
|
|
|
|
- name: Install cibuildwheel
|
|
run: |
|
|
python -m pip install -U pip
|
|
python -m pip install "cibuildwheel>=2.4,<3"
|
|
|
|
- name: Build manylinux_x86_64
|
|
env:
|
|
CIBW_BUILD: ${{ matrix.python }}-manylinux_x86_64
|
|
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
|
|
run: python -m cibuildwheel --output-dir wheelhouse
|
|
|
|
- name: Build manylinux_i686
|
|
env:
|
|
CIBW_BUILD: ${{ matrix.python }}-manylinux_i686
|
|
CIBW_MANYLINUX_I686_IMAGE: manylinux1
|
|
run: python -m cibuildwheel --output-dir wheelhouse
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: wheel-${{ matrix.python }}-manylinux1
|
|
path: ./wheelhouse/*.whl
|
|
if-no-files-found: error
|
|
|
|
make_sdist:
|
|
name: Make SDist
|
|
runs-on: macos-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
# Build sdist on lowest supported Python
|
|
python-version: '3.7'
|
|
|
|
- name: Build SDist
|
|
run: |
|
|
set -ex
|
|
python -m pip install -U pip build
|
|
python -m build --sdist .
|
|
|
|
- name: Test SDist
|
|
run: |
|
|
python -m pip install dist/*.gz
|
|
cd ..
|
|
python -c "from pymongo import has_c; assert has_c()"
|
|
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: "sdist"
|
|
path: ./dist/*.tar.gz
|
|
|
|
collect_dist:
|
|
runs-on: ubuntu-latest
|
|
needs: [build_wheels, build_manylinux1_wheels, make_sdist]
|
|
name: Download Wheels
|
|
steps:
|
|
- name: Download all workflow run artifacts
|
|
uses: actions/download-artifact@v4
|
|
- name: Flatten directory
|
|
working-directory: .
|
|
run: |
|
|
find . -mindepth 2 -type f -exec mv {} . \;
|
|
find . -type d -empty -delete
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: all-dist-${{ github.job }}
|
|
path: "./*"
|
|
|
|
publish:
|
|
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi
|
|
needs: [collect_dist]
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
runs-on: ubuntu-latest
|
|
environment: release
|
|
permissions:
|
|
id-token: write
|
|
steps:
|
|
- name: Download all the dists
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: all-dist-${{ github.job }}
|
|
path: dist/
|
|
- name: Publish distribution 📦 to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|