Build wheels and deploy #79
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 and deploy | |
on: | |
# this workflow can only be manually triggered for now. | |
workflow_dispatch: | |
inputs: | |
deploy: | |
description: 'Where to deploy the artifacts? Only build (build), deploy to test PyPI (test), or deploy to PyPI (prod).' | |
required: true | |
type: choice | |
default: 'build' | |
options: | |
- build | |
- test | |
- prod | |
jobs: | |
build-wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [macOS-latest, ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.11' | |
- name: Upgrade pip | |
run: | | |
python3 -m pip install --upgrade pip | |
- name: Install cibuildwheel | |
run: | | |
python3 -m pip install cibuildwheel pybind11-stubgen==1.1 | |
- name: Install dependencies | |
shell: bash | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
# Update & upgrade package lists | |
sudo apt-get update -y | |
sudo apt-get upgrade | |
# Deal with Github CI limitation | |
# https://github.com/actions/runner-images/issues/6399#issuecomment-1285011525 | |
sudo apt install -y libunwind-dev | |
# Generic dependencies | |
sudo apt-get install cmake libopenblas-dev | |
# Install VRS dependencies | |
sudo apt-get install -o Acquire::Retries=5 \ | |
libgtest-dev libgmock-dev \ | |
libfmt-dev \ | |
libturbojpeg-dev libpng-dev \ | |
liblz4-dev libzstd-dev libxxhash-dev \ | |
libboost-chrono-dev \ | |
libboost-date-time-dev \ | |
libboost-filesystem-dev \ | |
libboost-iostreams-dev \ | |
libboost-system-dev \ | |
libboost-thread-dev | |
# Clean APT cache | |
sudo apt-get clean | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
# Install system deps with Homebrew | |
brew install cmake | |
# VRS dependencies | |
brew install boost fmt googletest glog lz4 zstd xxhash libpng jpeg-turbo | |
# Install gsed for easy string replacement | |
brew install gsed | |
else | |
echo "$RUNNER_OS not supported" | |
exit 1 | |
fi | |
- name: Install projectaria_tools | |
run: | | |
# Build and install Python bindings | |
CMAKE_BUILD_PARALLEL_LEVEL=4 pip3 install . | |
# remove the build folder | |
rm -rf build | |
- name: Generate stubs | |
run: | | |
python3 generate_stubs.py | |
- name: Re-generate python package with stubs | |
run: | | |
CMAKE_BUILD_PARALLEL_LEVEL=4 pip3 install . | |
# remove the build folder | |
rm -rf build | |
- name: Build wheels for CPython | |
run: | | |
CMAKE_BUILD_PARALLEL_LEVEL=4 python3 -m cibuildwheel --output-dir dist | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: python-package-distributions | |
path: dist | |
publish-to-pypi: | |
runs-on: ubuntu-latest | |
needs: | |
- build-wheels | |
steps: | |
- name: Download wheels from previous jobs | |
# by default this will download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
# PyPI publish action uploads everything under dist/* by default | |
path: dist | |
- name: Display the list of artifacts | |
run: ls -R dist | |
- name: Publish to Test PyPI | |
if: github.event.inputs.deploy == 'test' | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_TOKEN_PROJECTARIA_TOOLS }} | |
repository_url: https://test.pypi.org/legacy/ | |
skip_existing: true | |
verbose: true | |
- name: Publish to PyPI | |
if: github.event.inputs.deploy == 'prod' | |
uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN_PROJECTARIA_TOOLS_DEV }} | |
skip_existing: true | |
verbose: true |