Add pypi package publishing in CI/CD #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build wheels | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- release-* | |
- '*wheel*' # must quote since "*" is a YAML reserved character; we want a string | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- '*wheel*' # must quote since "*" is a YAML reserved character; we want a string | |
workflow_dispatch: | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, macos-12, windows-2022] | |
# `windows-2022, ` blocked by https://github.com/pybind/pybind11/issues/3445#issuecomment-1525500927 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Brew setup on macOS' # x-ref c8e49ba8f8b9ce | |
if: ${{ startsWith(matrix.os, 'macos-') == true }} | |
run: | | |
set -e pipefail | |
brew install automake pkg-config ninja | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.14.1 | |
env: | |
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28" | |
CIBW_SKIP: "*-win32 cp27-* cp35-* cp36-* cp37-* pp* *_i686 *musllinux*" | |
CIBW_ARCHS_MACOS: "x86_64 arm64" | |
CIBW_BUILD_VERBOSITY: 3 | |
MACOSX_DEPLOYMENT_TARGET: "12.0" | |
with: | |
package-dir: "apis/python" | |
output-dir: wheelhouse | |
config-file: "{package}/pyproject.toml" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
path: './wheelhouse/*.whl' | |
# TODO: Needs support for pulling in the root directory | |
# build_sdist: | |
# name: Build source distribution | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/checkout@v3 | |
# | |
# - name: Build sdist | |
# run: pipx run build --sdist | |
# | |
# - uses: actions/upload-artifact@v3 | |
# with: | |
# path: dist/*.tar.gz | |
upload_test_pypi: | |
# needs: [build_wheels, build_sdist] | |
needs: [build_wheels] | |
runs-on: ubuntu-latest | |
# environment: pypi | |
permissions: | |
id-token: write | |
# if: github.event_name == 'release' && github.event.action == 'published' | |
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this) | |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
outputs: | |
package_version: ${{ steps.get_package_version.outputs.package_version }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: 'cibw-*' | |
path: dist | |
merge-multiple: true | |
- id: get_package_version | |
run: | | |
echo "package_version=$(ls dist/ | head -n 1 | cut -d - -f 2)" | |
echo "package_version=$(ls dist/ | head -n 1 | cut -d - -f 2)" >> "$GITHUB_OUTPUT" | |
- uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: ${{ secrets.TEST_PYPI_USERNAME }} | |
password: ${{ secrets.TEST_PYPI_PASSWORD }} | |
repository-url: https://test.pypi.org/legacy/ | |
test_pypi_package: | |
needs: [upload_test_pypi] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- env: | |
PACKAGE_VERSION: ${{ needs.upload_test_pypi.outputs.package_version }} | |
run: | | |
pip install -r apis/python/requirements-py.txt | |
pip install --only-binary ":all:" -i https://test.pypi.org/simple/ tiledb-vector-search==$PACKAGE_VERSION | |
- run: | | |
python -c "import tiledb.vector_search" | |
# upload_pypi: | |
# - uses: actions/download-artifact@v4 | |
# with: | |
# # unpacks all CIBW artifacts into dist/ | |
# pattern: 'cibw-*' | |
# path: dist | |
# merge-multiple: true | |
# | |
# - uses: pypa/gh-action-pypi-publish@release/v1 | |
# with: | |
# user: ${{ secrets.TEST_PYPI_USERNAME }} | |
# password: ${{ secrets.TEST_PYPI_PASSWORD }} | |
# repository-url: https://test.pypi.org/legacy/ |