|
| 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 | +# Publish the paimon Python binding to PyPI. |
| 19 | +# Trigger: push tag only (e.g. v0.1.0). |
| 20 | +# Pre-release tags (containing '-') publish to TestPyPI; release tags publish to PyPI. |
| 21 | +# |
| 22 | +# Token auth: add secrets PYPI_API_TOKEN / TEST_PYPI_API_TOKEN for publishing. |
| 23 | + |
| 24 | +name: Release Python Binding |
| 25 | + |
| 26 | +on: |
| 27 | + push: |
| 28 | + tags: |
| 29 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 30 | + - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +concurrency: |
| 34 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} |
| 35 | + cancel-in-progress: true |
| 36 | + |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + |
| 40 | +jobs: |
| 41 | + sdist: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v6 |
| 45 | + |
| 46 | + - uses: PyO3/maturin-action@v1 |
| 47 | + with: |
| 48 | + working-directory: bindings/python |
| 49 | + command: sdist |
| 50 | + args: -o dist |
| 51 | + |
| 52 | + - name: Upload sdist |
| 53 | + uses: actions/upload-artifact@v4 |
| 54 | + with: |
| 55 | + name: wheels-sdist |
| 56 | + path: bindings/python/dist |
| 57 | + |
| 58 | + wheels: |
| 59 | + runs-on: ${{ matrix.os }} |
| 60 | + strategy: |
| 61 | + matrix: |
| 62 | + include: |
| 63 | + - { os: windows-latest } |
| 64 | + - { os: macos-15-intel, target: "x86_64-apple-darwin" } |
| 65 | + - { os: macos-latest, target: "aarch64-apple-darwin" } |
| 66 | + - { os: ubuntu-latest, target: "x86_64" } |
| 67 | + - { os: ubuntu-latest, target: "aarch64", manylinux: "manylinux_2_28" } |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v6 |
| 70 | + |
| 71 | + - uses: PyO3/maturin-action@v1 |
| 72 | + with: |
| 73 | + working-directory: bindings/python |
| 74 | + target: ${{ matrix.target }} |
| 75 | + command: build |
| 76 | + args: --release -o dist |
| 77 | + manylinux: ${{ matrix.manylinux || 'auto' }} |
| 78 | + |
| 79 | + - name: Upload wheels |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: wheels-${{ matrix.os }}-${{ matrix.target || 'native' }} |
| 83 | + path: bindings/python/dist |
| 84 | + |
| 85 | + release: |
| 86 | + name: Publish to PyPI |
| 87 | + runs-on: ubuntu-latest |
| 88 | + permissions: |
| 89 | + contents: read |
| 90 | + needs: [sdist, wheels] |
| 91 | + if: startsWith(github.ref, 'refs/tags/') |
| 92 | + steps: |
| 93 | + - uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + pattern: wheels-* |
| 96 | + merge-multiple: true |
| 97 | + path: bindings/python/dist |
| 98 | + |
| 99 | + - name: Publish to TestPyPI |
| 100 | + if: contains(github.ref, '-') |
| 101 | + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e |
| 102 | + with: |
| 103 | + repository-url: https://test.pypi.org/legacy/ |
| 104 | + skip-existing: true |
| 105 | + packages-dir: bindings/python/dist |
| 106 | + password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 107 | + |
| 108 | + - name: Publish to PyPI |
| 109 | + if: ${{ !contains(github.ref, '-') }} |
| 110 | + uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e |
| 111 | + with: |
| 112 | + skip-existing: true |
| 113 | + packages-dir: bindings/python/dist |
| 114 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments