|
| 1 | +name: Upload Python Package to PyPI when a Release is Created |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build_wheels: |
| 9 | + name: Build wheels on ${{ matrix.os }} |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + os: [ ubuntu-22.04, windows-2022, macos-11, macos-12, macos-13, macos-14 ] |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - uses: actions/setup-python@v5 |
| 21 | + with: |
| 22 | + python-version: '3.11' |
| 23 | + |
| 24 | + - name: Install poetry |
| 25 | + run: pip install poetry |
| 26 | + |
| 27 | + # - name: Set version |
| 28 | + # run: python -m poetry version "${{ inputs.version }}" |
| 29 | + # if: "${{ github.event.inputs.version != 'main' }}" |
| 30 | + |
| 31 | + # Publish the source distribution with the version that's in |
| 32 | + # the repository, otherwise the tests will fail |
| 33 | + - name: Compile source distribution |
| 34 | + run: python3 -m poetry build --format=sdist |
| 35 | + if: startsWith(matrix.os, 'ubuntu') |
| 36 | + |
| 37 | + - name: Build wheels |
| 38 | + |
| 39 | + with: |
| 40 | + output-dir: wheelhouse |
| 41 | + config-file: "pyproject.toml" |
| 42 | + env: |
| 43 | + # Ignore 32 bit architectures |
| 44 | + CIBW_ARCHS: "auto64" |
| 45 | + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.8,<3.12" |
| 46 | + CIBW_TEST_REQUIRES: "pytest==7.4.2 moto==5.0.1" |
| 47 | + CIBW_TEST_EXTRAS: "s3fs,glue" |
| 48 | + CIBW_TEST_COMMAND: "pytest {project}/tests/avro/test_decoder.py" |
| 49 | + # There is an upstream issue with installing on MacOSX |
| 50 | + # https://github.com/pypa/cibuildwheel/issues/1603 |
| 51 | + # Ignore tests for pypy since not all dependencies are compiled for it |
| 52 | + # and would require a local rust build chain |
| 53 | + CIBW_TEST_SKIP: "pp* *macosx*" |
| 54 | + |
| 55 | + - name: Add source distribution |
| 56 | + if: startsWith(matrix.os, 'ubuntu') |
| 57 | + run: ls -lah dist/* && cp dist/* wheelhouse/ |
| 58 | + |
| 59 | + - uses: actions/upload-artifact@v3 |
| 60 | + with: |
| 61 | + name: "release-${{ github.event.inputs.version }}" |
| 62 | + path: ./wheelhouse/* |
| 63 | + |
| 64 | + pypi-publish: |
| 65 | + name: Publish release to PyPI |
| 66 | + runs-on: ubuntu-latest |
| 67 | + environment: |
| 68 | + name: pypi |
| 69 | + url: https://pypi.org/p/pyiceberg-kevinliu |
| 70 | + permissions: |
| 71 | + id-token: write |
| 72 | + steps: |
| 73 | + # - uses: actions/checkout@v4 |
| 74 | + # - name: Set up Python |
| 75 | + # uses: actions/setup-python@v4 |
| 76 | + # with: |
| 77 | + # python-version: "3.x" |
| 78 | + # - name: Install dependencies |
| 79 | + # run: | |
| 80 | + # python -m pip install --upgrade pip |
| 81 | + # pip install setuptools wheel |
| 82 | + # - name: Build package |
| 83 | + # run: | |
| 84 | + # python setup.py sdist bdist_wheel # Could also be python -m build |
| 85 | + - name: Publish package distributions to PyPI |
| 86 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments