-
Notifications
You must be signed in to change notification settings - Fork 14
167 lines (146 loc) · 4.89 KB
/
release-python.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Python Wheels
on:
push:
branches: ["main"]
tags:
- "**"
pull_request:
workflow_dispatch:
concurrency:
group: wheels-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: ./bindings/python
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]
- [macos-14, macosx_*]
- [windows-2019, win_amd64]
python: ["cp39", "cp310", "cp311", "cp312", "cp313"]
exclude:
- buildplat: [macos-14, macosx_*]
python: "cp39"
include:
- buildplat: [macos-12, macosx_*]
python: "cp39"
steps:
- name: Checkout pymongoarrow
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- 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: 'bindings/python/pyproject.toml'
allow-prereleases: true
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Install pkg-config on MacOS
if: runner.os == 'macOS'
run: brew install pkg-config
- name: Install cibuildwheel
run: python -m pip install "cibuildwheel>=2.4,<3"
- name: Build MacOS Py39 Wheels
if: ${{ matrix.python == 'cp39' && matrix.buildplat[0] == 'macos-11' }}
env:
MACOS_TEST_SKIP: "*arm64"
CIBW_BUILD: cp39-macosx_*
MACOSX_DEPLOYMENT_TARGET: "10.14"
run: python -m cibuildwheel --output-dir wheelhouse
- name: Build wheels
if: ${{ matrix.buildplat[0] != 'macos-11' }}
env:
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
MACOSX_DEPLOYMENT_TARGET: "12.0"
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
path: ./bindings/python/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
persist-credentials: false
- uses: actions/setup-python@v5
with:
# Build sdist on lowest supported Python
python-version: '3.9'
- name: Install tox
run: |
python -m pip install tox
- name: Build SDist
working-directory: ./bindings/python
run: |
set -ex
export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
tox -e build-libbson
tox -e build-dist -- --sdist
- name: Test Sdist
working-directory: ./bindings/python
run: |
export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
python -m pip install dist/*.gz
cd ..
python -c "from pymongoarrow.lib import libbson_version"
- uses: actions/upload-artifact@v4
with:
name: "sdist"
path: ./bindings/python/dist/*.tar.gz
collect_dist:
runs-on: ubuntu-latest
needs: [build_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.run_id }}
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.run_id }}
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1