|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +name: Publish Python 🐍 distribution 📦 to PyPI |
| 19 | + |
| 20 | +on: |
| 21 | + push: |
| 22 | + tags: |
| 23 | + - '*' |
| 24 | + pull_request: |
| 25 | + branches: |
| 26 | + - main |
| 27 | + paths: |
| 28 | + - ".github/workflows/release_python.yml" |
| 29 | + workflow_dispatch: |
| 30 | + |
| 31 | +env: |
| 32 | + rust_msrv: "1.77.1" |
| 33 | + |
| 34 | +concurrency: |
| 35 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} |
| 36 | + cancel-in-progress: true |
| 37 | + |
| 38 | +permissions: |
| 39 | + contents: read |
| 40 | + |
| 41 | +jobs: |
| 42 | + sdist: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + - uses: PyO3/maturin-action@v1 |
| 47 | + with: |
| 48 | + working-directory: "bindings/python" |
| 49 | + command: sdist |
| 50 | + args: -o dist |
| 51 | + - name: Upload sdist |
| 52 | + uses: actions/upload-artifact@v3 |
| 53 | + with: |
| 54 | + name: wheels |
| 55 | + path: bindings/python/dist |
| 56 | + |
| 57 | + wheels: |
| 58 | + runs-on: "${{ matrix.os }}" |
| 59 | + strategy: |
| 60 | + matrix: |
| 61 | + include: |
| 62 | + - { os: windows-latest } |
| 63 | + - { os: macos-latest, target: "universal2-apple-darwin" } |
| 64 | + - { os: ubuntu-latest, target: "x86_64" } |
| 65 | + - { os: ubuntu-latest, target: "aarch64" } |
| 66 | + - { os: ubuntu-latest, target: "armv7l" } |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + - uses: actions/setup-python@v4 |
| 70 | + with: |
| 71 | + python-version: 3.9 |
| 72 | + - name: Setup Rust toolchain |
| 73 | + uses: ./.github/actions/setup-builder |
| 74 | + with: |
| 75 | + rust-version: ${{ env.rust_msrv }} |
| 76 | + - uses: PyO3/maturin-action@v1 |
| 77 | + with: |
| 78 | + target: ${{ matrix.target }} |
| 79 | + manylinux: auto |
| 80 | + working-directory: "bindings/python" |
| 81 | + command: build |
| 82 | + args: --release -o dist |
| 83 | + env: |
| 84 | + # Workaround ring 0.17 build issue |
| 85 | + CFLAGS_aarch64_unknown_linux_gnu: "-D__ARM_ARCH=8" |
| 86 | + - name: Upload wheels |
| 87 | + uses: actions/upload-artifact@v3 |
| 88 | + with: |
| 89 | + name: wheels |
| 90 | + path: bindings/python/dist |
| 91 | + |
| 92 | + pypi-publish: |
| 93 | + name: Publish Python 🐍 distribution 📦 to Pypi |
| 94 | + needs: [ sdist, wheels ] |
| 95 | + runs-on: ubuntu-latest |
| 96 | + # Only publish to PyPi if the tag is not a pre-release |
| 97 | + if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-') }} |
| 98 | + |
| 99 | + environment: |
| 100 | + name: pypi |
| 101 | + url: https://pypi.org/p/pyiceberg_core |
| 102 | + |
| 103 | + permissions: |
| 104 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 105 | + |
| 106 | + steps: |
| 107 | + - name: Download all the dists |
| 108 | + uses: actions/download-artifact@v3 |
| 109 | + with: |
| 110 | + name: wheels |
| 111 | + path: bindings/python/dist |
| 112 | + - name: Publish to PyPI |
| 113 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 114 | + |
| 115 | + with: |
| 116 | + skip-existing: true |
| 117 | + packages-dir: bindings/python/dist |
| 118 | + |
| 119 | + testpypi-publish: |
| 120 | + name: Publish Python 🐍 distribution 📦 to TestPypi |
| 121 | + needs: [ sdist, linux ] |
| 122 | + runs-on: ubuntu-latest |
| 123 | + # Only publish to TestPyPi if the tag is a pre-release |
| 124 | + if: ${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, '-')}} |
| 125 | + |
| 126 | + environment: |
| 127 | + name: testpypi |
| 128 | + url: https://test.pypi.org/p/pyiceberg_core |
| 129 | + |
| 130 | + permissions: |
| 131 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 132 | + |
| 133 | + steps: |
| 134 | + - name: Download all the dists |
| 135 | + uses: actions/download-artifact@v3 |
| 136 | + with: |
| 137 | + name: wheels |
| 138 | + path: bindings/python/dist |
| 139 | + - name: Publish to TestPyPI |
| 140 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 141 | + with: |
| 142 | + repository-url: https://test.pypi.org/legacy/ |
| 143 | + skip-existing: true |
| 144 | + packages-dir: bindings/python/dist |
0 commit comments