|
1 | | -name: Python Wheels |
| 1 | +name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - "[0-9]+.[0-9]+.[0-9]+" |
7 | | - - "[0-9]+.[0-9]+.[0-9]+.post[0-9]+" |
8 | | - - "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+" |
9 | | - - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" |
10 | 4 | workflow_dispatch: |
11 | | - pull_request: |
12 | | - |
13 | | -concurrency: |
14 | | - group: wheels-${{ github.ref }} |
15 | | - cancel-in-progress: true |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "The new version to set" |
| 8 | + required: true |
| 9 | + following_version: |
| 10 | + description: "The post (dev) version to set" |
| 11 | + required: true |
| 12 | + dry_run: |
| 13 | + description: "Dry Run?" |
| 14 | + default: false |
| 15 | + type: boolean |
| 16 | + |
| 17 | +env: |
| 18 | + # Changes per repo |
| 19 | + PRODUCT_NAME: PyMongo |
| 20 | + # Changes per branch |
| 21 | + SILK_ASSET_GROUP: mongodb-python-driver |
16 | 22 |
|
17 | 23 | defaults: |
18 | 24 | run: |
19 | 25 | shell: bash -eux {0} |
20 | 26 |
|
21 | 27 | jobs: |
22 | | - build_wheels: |
23 | | - name: Build wheels for ${{ matrix.buildplat[1] }} |
24 | | - runs-on: ${{ matrix.buildplat[0] }} |
25 | | - strategy: |
26 | | - # Ensure that a wheel builder finishes even if another fails |
27 | | - fail-fast: false |
28 | | - matrix: |
29 | | - # Github Actions doesn't support pairing matrix values together, let's improvise |
30 | | - # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 |
31 | | - buildplat: |
32 | | - - [ubuntu-20.04, "manylinux_x86_64", "cp3*-manylinux_x86_64"] |
33 | | - - [ubuntu-20.04, "manylinux_aarch64", "cp3*-manylinux_aarch64"] |
34 | | - - [ubuntu-20.04, "manylinux_ppc64le", "cp3*-manylinux_ppc64le"] |
35 | | - - [ubuntu-20.04, "manylinux_s390x", "cp3*-manylinux_s390x"] |
36 | | - - [ubuntu-20.04, "manylinux_i686", "cp3*-manylinux_i686"] |
37 | | - - [windows-2019, "win_amd6", "cp3*-win_amd64"] |
38 | | - - [windows-2019, "win32", "cp3*-win32"] |
39 | | - - [macos-14, "macos", "cp*-macosx_*"] |
40 | | - |
| 28 | + pre-publish: |
| 29 | + environment: release |
| 30 | + runs-on: ubuntu-latest |
| 31 | + permissions: |
| 32 | + id-token: write |
| 33 | + contents: write |
41 | 34 | steps: |
42 | | - - name: Checkout pymongo |
43 | | - uses: actions/checkout@v4 |
44 | | - with: |
45 | | - fetch-depth: 0 |
46 | | - |
47 | | - - uses: actions/setup-python@v5 |
48 | | - with: |
49 | | - cache: 'pip' |
50 | | - python-version: 3.8 |
51 | | - cache-dependency-path: 'pyproject.toml' |
52 | | - allow-prereleases: true |
53 | | - |
54 | | - - name: Set up QEMU |
55 | | - if: runner.os == 'Linux' |
56 | | - uses: docker/setup-qemu-action@v3 |
57 | | - with: |
58 | | - platforms: all |
59 | | - |
60 | | - - name: Install cibuildwheel |
61 | | - # Note: the default manylinux is manylinux2014 |
62 | | - run: | |
63 | | - python -m pip install -U pip |
64 | | - python -m pip install "cibuildwheel>=2.17,<3" |
65 | | -
|
66 | | - - name: Build wheels |
67 | | - env: |
68 | | - CIBW_BUILD: ${{ matrix.buildplat[2] }} |
69 | | - run: python -m cibuildwheel --output-dir wheelhouse |
70 | | - |
71 | | - - name: Build manylinux1 wheels |
72 | | - if: ${{ matrix.buildplat[1] == 'manylinux_x86_64' || matrix.buildplat[1] == 'manylinux_i686' }} |
73 | | - env: |
74 | | - CIBW_MANYLINUX_X86_64_IMAGE: manylinux1 |
75 | | - CIBW_MANYLINUX_I686_IMAGE: manylinux1 |
76 | | - CIBW_BUILD: "cp38-${{ matrix.buildplat[1] }} cp39-${{ matrix.buildplat[1] }}" |
77 | | - run: python -m cibuildwheel --output-dir wheelhouse |
78 | | - |
79 | | - - name: Assert all versions in wheelhouse |
80 | | - if: ${{ ! startsWith(matrix.buildplat[1], 'macos') }} |
81 | | - run: | |
82 | | - ls wheelhouse/*cp38*.whl |
83 | | - ls wheelhouse/*cp39*.whl |
84 | | - ls wheelhouse/*cp310*.whl |
85 | | - ls wheelhouse/*cp311*.whl |
86 | | - ls wheelhouse/*cp312*.whl |
87 | | -
|
88 | | - - uses: actions/upload-artifact@v4 |
| 35 | + - uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 |
89 | 36 | with: |
90 | | - name: wheel-${{ matrix.buildplat[1] }} |
91 | | - path: ./wheelhouse/*.whl |
92 | | - if-no-files-found: error |
93 | | - |
94 | | - make_sdist: |
95 | | - name: Make SDist |
96 | | - runs-on: macos-13 |
97 | | - steps: |
98 | | - - uses: actions/checkout@v4 |
| 37 | + app_id: ${{ vars.APP_ID }} |
| 38 | + private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 39 | + - uses: mongodb-labs/drivers-github-tools/setup@v2 |
99 | 40 | with: |
100 | | - fetch-depth: 0 |
101 | | - |
102 | | - - uses: actions/setup-python@v5 |
| 41 | + aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} |
| 42 | + aws_region_name: ${{ vars.AWS_REGION_NAME }} |
| 43 | + aws_secret_id: ${{ secrets.AWS_SECRET_ID }} |
| 44 | + artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} |
| 45 | + - uses: mongodb-labs/drivers-github-tools/python/pre-publish@v2 |
103 | 46 | with: |
104 | | - # Build sdist on lowest supported Python |
105 | | - python-version: '3.8' |
106 | | - |
107 | | - - name: Build SDist |
108 | | - run: | |
109 | | - set -ex |
110 | | - python -m pip install -U pip build |
111 | | - python -m build --sdist . |
112 | | -
|
113 | | - - name: Test SDist |
114 | | - run: | |
115 | | - python -m pip install dist/*.gz |
116 | | - cd .. |
117 | | - python -c "from pymongo import has_c; assert has_c()" |
| 47 | + version: ${{ inputs.version }} |
| 48 | + dry_run: ${{ inputs.dry_run }} |
118 | 49 |
|
119 | | - - uses: actions/upload-artifact@v4 |
120 | | - with: |
121 | | - name: "sdist" |
122 | | - path: ./dist/*.tar.gz |
| 50 | + build-dist: |
| 51 | + needs: [pre-publish] |
| 52 | + uses: ./.github/workflows/dist.yml |
123 | 53 |
|
124 | | - collect_dist: |
125 | | - runs-on: ubuntu-latest |
126 | | - needs: [build_wheels, make_sdist] |
127 | | - name: Download Wheels |
128 | | - steps: |
129 | | - - name: Download all workflow run artifacts |
130 | | - uses: actions/download-artifact@v4 |
131 | | - - name: Flatten directory |
132 | | - working-directory: . |
133 | | - run: | |
134 | | - find . -mindepth 2 -type f -exec mv {} . \; |
135 | | - find . -type d -empty -delete |
136 | | - - uses: actions/upload-artifact@v4 |
137 | | - with: |
138 | | - name: all-dist-${{ github.run_id }} |
139 | | - path: "./*" |
| 54 | + static-scan: |
| 55 | + needs: [pre-publish] |
| 56 | + uses: ./.github/workflows/codeql.yml |
| 57 | + with: |
| 58 | + ref: ${{ inputs.version }} |
140 | 59 |
|
141 | 60 | publish: |
142 | | - # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-the-distribution-to-pypi |
143 | | - needs: [collect_dist] |
144 | | - if: startsWith(github.ref, 'refs/tags/') |
| 61 | + needs: [build-dist, static-scan] |
145 | 62 | runs-on: ubuntu-latest |
146 | 63 | environment: release |
147 | 64 | permissions: |
148 | 65 | id-token: write |
| 66 | + contents: write |
| 67 | + security-events: write |
149 | 68 | steps: |
150 | | - - name: Download all the dists |
151 | | - uses: actions/download-artifact@v4 |
152 | | - with: |
153 | | - name: all-dist-${{ github.run_id }} |
154 | | - path: dist/ |
155 | | - - name: Publish distribution 📦 to PyPI |
156 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 69 | + - uses: mongodb-labs/drivers-github-tools/secure-checkout@v2 |
| 70 | + with: |
| 71 | + app_id: ${{ vars.APP_ID }} |
| 72 | + private_key: ${{ secrets.APP_PRIVATE_KEY }} |
| 73 | + - uses: mongodb-labs/drivers-github-tools/setup@v2 |
| 74 | + with: |
| 75 | + aws_role_arn: ${{ secrets.AWS_ROLE_ARN }} |
| 76 | + aws_region_name: ${{ vars.AWS_REGION_NAME }} |
| 77 | + aws_secret_id: ${{ secrets.AWS_SECRET_ID }} |
| 78 | + artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }} |
| 79 | + - uses: mongodb-labs/drivers-github-tools/python/publish@v2 |
| 80 | + with: |
| 81 | + version: ${{ inputs.version }} |
| 82 | + following_version: ${{ inputs.following_version }} |
| 83 | + product_name: ${{ env.PRODUCT_NAME }} |
| 84 | + silk_asset_group: ${{ env.SILK_ASSET_GROUP }} |
| 85 | + token: ${{ github.token }} |
| 86 | + dry_run: ${{ inputs.dry_run }} |
0 commit comments