|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | +# |
| 19 | + |
| 20 | +name: "Build PyPI Artifacts" |
| 21 | + |
| 22 | +on: |
| 23 | + workflow_call: |
| 24 | + inputs: |
| 25 | + VERSION: |
| 26 | + required: true |
| 27 | + type: string |
| 28 | + |
| 29 | +jobs: |
| 30 | + pypi-build-artifacts: |
| 31 | + name: Build artifacts for PyPi on ${{ matrix.os }} |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + strategy: |
| 34 | + matrix: |
| 35 | + os: [ ubuntu-22.04, windows-2022, macos-13, macos-14 ] |
| 36 | + |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + fetch-depth: 1 |
| 41 | + |
| 42 | + - uses: actions/setup-python@v5 |
| 43 | + with: |
| 44 | + python-version: | |
| 45 | + 3.9 |
| 46 | + 3.10 |
| 47 | + 3.11 |
| 48 | + 3.12 |
| 49 | +
|
| 50 | + - name: Install poetry |
| 51 | + run: make install-poetry |
| 52 | + |
| 53 | + - name: Set version with RC |
| 54 | + env: |
| 55 | + VERSION: ${{ inputs.VERSION }} |
| 56 | + run: python -m poetry version "${{ env.VERSION }}" |
| 57 | + |
| 58 | + # Publish the source distribution with the version that's in |
| 59 | + # the repository, otherwise the tests will fail |
| 60 | + - name: Compile source distribution |
| 61 | + run: python3 -m poetry build --format=sdist |
| 62 | + if: startsWith(matrix.os, 'ubuntu') |
| 63 | + |
| 64 | + - name: Build wheels |
| 65 | + uses: pypa/cibuildwheel@v2.23.3 |
| 66 | + with: |
| 67 | + output-dir: wheelhouse |
| 68 | + config-file: "pyproject.toml" |
| 69 | + env: |
| 70 | + # Ignore 32 bit architectures |
| 71 | + CIBW_ARCHS: "auto64" |
| 72 | + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9,<3.13" |
| 73 | + CIBW_TEST_REQUIRES: "pytest==7.4.2 moto==5.0.1" |
| 74 | + CIBW_TEST_COMMAND: "pytest {project}/tests/avro/test_decoder.py" |
| 75 | + # Ignore tests for pypy since not all dependencies are compiled for it |
| 76 | + # and would require a local rust build chain |
| 77 | + CIBW_TEST_SKIP: "pp*" |
| 78 | + |
| 79 | + - name: Add source distribution |
| 80 | + if: startsWith(matrix.os, 'ubuntu') |
| 81 | + run: ls -lah dist/* && cp dist/* wheelhouse/ |
| 82 | + |
| 83 | + - uses: actions/upload-artifact@v4 |
| 84 | + with: |
| 85 | + name: "pypi-release-candidate-${{ matrix.os }}" |
| 86 | + path: ./wheelhouse/* |
| 87 | + |
| 88 | + pypi-merge-artifacts: |
| 89 | + runs-on: ubuntu-latest |
| 90 | + needs: |
| 91 | + - pypi-build-artifacts |
| 92 | + steps: |
| 93 | + - name: Merge Artifacts |
| 94 | + uses: actions/upload-artifact/merge@v4 |
| 95 | + with: |
| 96 | + name: "pypi-release-candidate-${{ inputs.VERSION }}" |
| 97 | + pattern: pypi-release-candidate* |
| 98 | + delete-merged: true |
0 commit comments