From 4a550e55cb0e668b8c4ceacb1fcbe8b5a034d85c Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 21 Nov 2024 18:35:51 -0500 Subject: [PATCH] CI: Automate pypi wheel publishing --- .github/workflows/pypi_publish.yml | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/pypi_publish.yml diff --git a/.github/workflows/pypi_publish.yml b/.github/workflows/pypi_publish.yml new file mode 100644 index 000000000..525ce52da --- /dev/null +++ b/.github/workflows/pypi_publish.yml @@ -0,0 +1,68 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: Build and upload to PyPI + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.21.3 + env: + CIBW_BEFORE_ALL: cd python + + - uses: actions/upload-artifact@v4.4.0 + with: + name: artifacts-${{ matrix.os }} + path: ./wheelhouse/*.whl + + upload_pypi: + needs: [build_wheels] + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/project/arrow-nanoarrow/ + permissions: + id-token: write + # TODO: add back in the below condition when productionalized + # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/download-artifact@v4.1.8 + with: + # unpacks default artifact into dist/ + # https://github.com/actions/upload-artifact/issues/480#issuecomment-1937762859 + pattern: artifacts-* + merge-multiple: true + path: dist + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ # currently pointing to test env