1- name : Python Wheels
1+ name : Release
22
33on :
4- push :
5- branches : ["main"]
6- tags :
7- - " **"
8- pull_request :
94 workflow_dispatch :
5+ inputs :
6+ following_version :
7+ description : " The post (dev) version to set"
8+ dry_run :
9+ description : " Dry Run?"
10+ default : false
11+ type : boolean
1012 schedule :
1113 - cron : ' 30 5 * * *'
1214
15+ env :
16+ # Changes per repo
17+ PRODUCT_NAME : PyMongoArrow
18+ # Constant
19+ # inputs will be empty on a scheduled run. so, we only set dry_run
20+ # to 'false' when the input is set to 'false'.
21+ DRY_RUN : ${{ ! contains(inputs.dry_run, 'false') }}
22+ FOLLOWING_VERSION : ${{ inputs.following_version || '' }}
23+
1324concurrency :
1425 group : wheels-${{ github.ref }}
1526 cancel-in-progress : true
@@ -20,142 +31,51 @@ defaults:
2031 shell : bash -eux {0}
2132
2233jobs :
23- build_wheels :
24- name : Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
25- runs-on : ${{ matrix.buildplat[0] }}
26- strategy :
27- # Ensure that a wheel builder finishes even if another fails
28- fail-fast : false
29- matrix :
30- # Github Actions doesn't support pairing matrix values together, let's improvise
31- # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
32- buildplat :
33- - [ubuntu-24.04, manylinux_x86_64]
34- - [ubuntu-24.04, manylinux_aarch64]
35- - [macos-14, macosx_*]
36- - [windows-2019, win_amd64]
37- python : ["cp39", "cp310", "cp311", "cp312", "cp313"]
38- exclude :
39- - buildplat : [macos-14, macosx_*]
40- python : " cp39"
41- include :
42- - buildplat : [macos-13, macosx_*]
43- python : " cp39"
44-
45- steps :
46- - name : Checkout pymongoarrow
47- uses : actions/checkout@v4
48- with :
49- persist-credentials : false
50-
51- - name : Set up python version
52- run : |
53- export PYTHON_VERSION=$(sed 's/^cp3/3./' <<< ${{ matrix.python }} )
54- echo "PYTHON_VERSION=$PYTHON_VERSION" >> $GITHUB_ENV
55-
56- - uses : actions/setup-python@v5
57- with :
58- python-version : ${{env.PYTHON_VERSION}}
59- cache : ' pip'
60- cache-dependency-path : ' bindings/python/pyproject.toml'
61- allow-prereleases : true
62-
63- - name : Set up QEMU
64- if : matrix.buildplat[1] == 'manylinux_aarch64'
65- uses : docker/setup-qemu-action@v3
66- with :
67- # setup-qemu-action by default uses `tonistiigi/binfmt:latest` image,
68- # which is out of date. This causes seg faults during build.
69- # Here we manually fix the version.
70- image : tonistiigi/binfmt:qemu-v8.1.5
71- platforms : arm64
72-
73- - name : Install pkg-config on MacOS
74- if : runner.os == 'macOS'
75- run : brew install pkg-config
76-
77- - name : Install cibuildwheel
78- run : python -m pip install "cibuildwheel>=2.4,<3"
79-
80- - name : Build MacOS Py39 Wheels
81- if : ${{ matrix.python == 'cp39' && matrix.buildplat[0] == 'macos-11' }}
82- env :
83- MACOS_TEST_SKIP : " *arm64"
84- CIBW_BUILD : cp39-macosx_*
85- MACOSX_DEPLOYMENT_TARGET : " 10.14"
86- run : python -m cibuildwheel --output-dir wheelhouse
87-
88- - name : Build wheels
89- if : ${{ matrix.buildplat[0] != 'macos-11' }}
90- env :
91- CIBW_BUILD : ${{ matrix.python }}-${{ matrix.buildplat[1] }}
92- MACOSX_DEPLOYMENT_TARGET : " 12.0"
93- run : python -m cibuildwheel --output-dir wheelhouse
94-
95- - uses : actions/upload-artifact@v4
96- with :
97- name : ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
98- path : ./bindings/python/wheelhouse/*.whl
99- if-no-files-found : error
100-
101- make_sdist :
102- name : Make SDist
103- runs-on : macos-latest
34+ pre-publish :
35+ environment : release
36+ runs-on : ubuntu-latest
37+ if : github.repository_owner == 'mongodb' || github.event_name == 'workflow_dispatch'
38+ permissions :
39+ id-token : write
40+ contents : write
41+ outputs :
42+ version : ${{ steps.pre-publish.outputs.version }}
10443 steps :
105- - uses : actions/ checkout@v4
44+ - uses : mongodb-labs/drivers-github-tools/secure- checkout@v2
10645 with :
107- persist-credentials : false
108-
109- - uses : actions/setup-python@v5
46+ app_id : ${{ vars.APP_ID }}
47+ private_key : ${{ secrets.APP_PRIVATE_KEY }}
48+ - uses : mongodb-labs/drivers-github-tools/setup@v2
11049 with :
111- # Build sdist on lowest supported Python
112- python-version : ' 3.9'
113-
50+ aws_role_arn : ${{ secrets.AWS_ROLE_ARN }}
51+ aws_region_name : ${{ vars.AWS_REGION_NAME }}
52+ aws_secret_id : ${{ secrets.AWS_SECRET_ID }}
53+ artifactory_username : ${{ vars.ARTIFACTORY_USERNAME }}
11454 - name : Install tox
11555 run : |
11656 python -m pip install tox
117-
118- - name : Build SDist
57+ - name : Build Libbson
11958 working-directory : ./bindings/python
12059 run : |
12160 set -ex
12261 export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
12362 tox -e build-libbson
124- tox -e build-dist -- --sdist
125-
126- - name : Test Sdist
127- working-directory : ./bindings/python
128- run : |
129- export LIBBSON_INSTALL_DIR="$(pwd)/libbson"
130- python -m pip install dist/*.gz
131- cd ..
132- python -c "from pymongoarrow.lib import libbson_version"
133-
134- - uses : actions/upload-artifact@v4
63+ echo "LIBBSON_INSTALL_DIR=$LIBBSON_INSTALL_DIR" >> $GITHUB_ENV
64+ - uses : mongodb-labs/drivers-github-tools/python-labs/pre-publish@v2
65+ id : pre-publish
13566 with :
136- name : " sdist "
137- path : ./bindings/python/dist/*.tar.gz
67+ dry_run : ${{ env.DRY_RUN }}
68+ working_directory : ./bindings/python
13869
139- collect_dist :
140- runs-on : ubuntu-latest
141- needs : [build_wheels, make_sdist]
142- name : Download Wheels
143- steps :
144- - name : Download all workflow run artifacts
145- uses : actions/download-artifact@v4
146- - name : Flatten directory
147- working-directory : .
148- run : |
149- find . -mindepth 2 -type f -exec mv {} . \;
150- find . -type d -empty -delete
151- - uses : actions/upload-artifact@v4
152- with :
153- name : all-dist-${{ github.run_id }}
154- path : " ./*"
70+ build-dist :
71+ needs : [pre-publish]
72+ uses : ./.github/workflows/dist-python.yml
73+ with :
74+ ref : ${{ needs.pre-publish.outputs.version }}
15575
15676 publish :
15777 # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi
158- needs : [collect_dist ]
78+ needs : [build-dist ]
15979 if : (github.repository_owner == 'mongodb-labs' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch'
16080 runs-on : ubuntu-latest
16181 environment : release
@@ -176,3 +96,31 @@ jobs:
17696 - name : Publish distribution 📦 to PyPI
17797 if : startsWith(github.ref, 'refs/tags/')
17898 uses : pypa/gh-action-pypi-publish@release/v1
99+
100+ post-publish :
101+ needs : [publish]
102+ runs-on : ubuntu-latest
103+ environment : release
104+ permissions :
105+ id-token : write
106+ contents : write
107+ attestations : write
108+ security-events : write
109+ steps :
110+ - uses : mongodb-labs/drivers-github-tools/secure-checkout@v2
111+ with :
112+ app_id : ${{ vars.APP_ID }}
113+ private_key : ${{ secrets.APP_PRIVATE_KEY }}
114+ - uses : mongodb-labs/drivers-github-tools/setup@v2
115+ with :
116+ aws_role_arn : ${{ secrets.AWS_ROLE_ARN }}
117+ aws_region_name : ${{ vars.AWS_REGION_NAME }}
118+ aws_secret_id : ${{ secrets.AWS_SECRET_ID }}
119+ artifactory_username : ${{ vars.ARTIFACTORY_USERNAME }}
120+ - uses : mongodb-labs/drivers-github-tools/python-labs/post-publish@v2
121+ with :
122+ following_version : ${{ env.FOLLOWING_VERSION }}
123+ product_name : ${{ env.PRODUCT_NAME }}
124+ token : ${{ github.token }}
125+ dry_run : ${{ env.DRY_RUN }}
126+ working_directory : ./bindings/python
0 commit comments