-
Notifications
You must be signed in to change notification settings - Fork 17
INTPYTHON-589 Add automated release support for pymongoarrow #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ef3bdb2
set up drivers-github-tools integration
blink1073 25b3434
do not require following version
blink1073 28abb2c
handle libbson
blink1073 76714cf
handle libbson
blink1073 2e91d73
fix dist
blink1073 54185ba
test with release
blink1073 de475bd
add security scan
blink1073 c603f8a
update release notes
blink1073 b20a615
Update bindings/python/RELEASE.md
blink1073 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| name: Python Dist | ||
|
|
||
| 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: | ||
| workflow_call: | ||
| inputs: | ||
| ref: | ||
| required: true | ||
| type: string | ||
|
|
||
| concurrency: | ||
| group: dist-${{ 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-24.04, manylinux_x86_64] | ||
| - [ubuntu-24.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-13, macosx_*] | ||
| python: "cp39" | ||
|
|
||
| steps: | ||
| - name: Checkout pymongoarrow | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| 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}} | ||
| allow-prereleases: true | ||
|
|
||
| - name: Set up QEMU | ||
| if: matrix.buildplat[1] == 'manylinux_aarch64' | ||
| uses: docker/setup-qemu-action@v3 | ||
| with: | ||
| # setup-qemu-action by default uses `tonistiigi/binfmt:latest` image, | ||
| # which is out of date. This causes seg faults during build. | ||
| # Here we manually fix the version. | ||
| image: tonistiigi/binfmt:qemu-v8.1.5 | ||
| platforms: arm64 | ||
|
|
||
| - 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: | ||
| 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: "./*" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,178 +1,126 @@ | ||
| name: Python Wheels | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| tags: | ||
| - "**" | ||
| pull_request: | ||
| workflow_dispatch: | ||
| inputs: | ||
| following_version: | ||
| description: "The post (dev) version to set" | ||
| dry_run: | ||
| description: "Dry Run?" | ||
| default: false | ||
| type: boolean | ||
| schedule: | ||
| - cron: '30 5 * * *' | ||
|
|
||
| env: | ||
| # Changes per repo | ||
| PRODUCT_NAME: PyMongoArrow | ||
| # Constant | ||
| # inputs will be empty on a scheduled run. so, we only set dry_run | ||
| # to 'false' when the input is set to 'false'. | ||
| DRY_RUN: ${{ ! contains(inputs.dry_run, 'false') }} | ||
| FOLLOWING_VERSION: ${{ inputs.following_version || '' }} | ||
|
|
||
| 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-24.04, manylinux_x86_64] | ||
| - [ubuntu-24.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-13, macosx_*] | ||
| python: "cp39" | ||
|
|
||
| steps: | ||
| - name: Checkout pymongoarrow | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| 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: matrix.buildplat[1] == 'manylinux_aarch64' | ||
| uses: docker/setup-qemu-action@v3 | ||
| with: | ||
| # setup-qemu-action by default uses `tonistiigi/binfmt:latest` image, | ||
| # which is out of date. This causes seg faults during build. | ||
| # Here we manually fix the version. | ||
| image: tonistiigi/binfmt:qemu-v8.1.5 | ||
| platforms: arm64 | ||
|
|
||
| - 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 | ||
| pre-publish: | ||
| environment: release | ||
| runs-on: ubuntu-latest | ||
| if: github.repository_owner == 'mongodb' || github.event_name == 'workflow_dispatch' | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| outputs: | ||
| version: ${{ steps.pre-publish.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| app_id: ${{ vars.APP_ID }} | ||
| private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| - uses: mongodb-labs/drivers-github-tools/setup@v2 | ||
| with: | ||
| # Build sdist on lowest supported Python | ||
| python-version: '3.9' | ||
|
|
||
| aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws_region_name: ${{ vars.AWS_REGION_NAME }} | ||
| aws_secret_id: ${{ secrets.AWS_SECRET_ID }} | ||
| artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} | ||
| - name: Install tox | ||
| run: | | ||
| python -m pip install tox | ||
|
|
||
| - name: Build SDist | ||
| - name: Build Libbson | ||
| 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 | ||
| echo "LIBBSON_INSTALL_DIR=$LIBBSON_INSTALL_DIR" >> $GITHUB_ENV | ||
| - uses: mongodb-labs/drivers-github-tools/python-labs/pre-publish@v2 | ||
| id: pre-publish | ||
| with: | ||
| name: "sdist" | ||
| path: ./bindings/python/dist/*.tar.gz | ||
| dry_run: ${{ env.DRY_RUN }} | ||
| working_directory: ./bindings/python | ||
|
|
||
| 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: "./*" | ||
| build-dist: | ||
| needs: [pre-publish] | ||
| uses: ./.github/workflows/dist-python.yml | ||
| with: | ||
| ref: ${{ needs.pre-publish.outputs.version }} | ||
|
||
|
|
||
| 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] | ||
| needs: [build-dist] | ||
| if: (github.repository_owner == 'mongodb-labs' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' | ||
| 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 package distributions to TestPyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
| skip-existing: true | ||
| attestations: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
| - name: Publish distribution 📦 to PyPI | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
|
||
| post-publish: | ||
| needs: [publish] | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| attestations: write | ||
| security-events: write | ||
| steps: | ||
| - uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 | ||
| with: | ||
| app_id: ${{ vars.APP_ID }} | ||
| private_key: ${{ secrets.APP_PRIVATE_KEY }} | ||
| - uses: mongodb-labs/drivers-github-tools/setup@v2 | ||
| with: | ||
| aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} | ||
| aws_region_name: ${{ vars.AWS_REGION_NAME }} | ||
| aws_secret_id: ${{ secrets.AWS_SECRET_ID }} | ||
| artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} | ||
| - uses: mongodb-labs/drivers-github-tools/python-labs/post-publish@v2 | ||
| with: | ||
| following_version: ${{ env.FOLLOWING_VERSION }} | ||
| product_name: ${{ env.PRODUCT_NAME }} | ||
| token: ${{ github.token }} | ||
| dry_run: ${{ env.DRY_RUN }} | ||
| working_directory: ./bindings/python | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we planning to standardize all our projects to
just+hatchat some future point?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yes. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you open a ticket to track that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: INTPYTHON-592 and https://jira.mongodb.org/browse/MOTOR-1455.