Skip to content

Build and release to PyPI #26

Build and release to PyPI

Build and release to PyPI #26

name: Build and release to PyPI
on:
workflow_dispatch:
inputs:
reduce-release-tag:
description: Reduce tag to build
required: true
default: v4.14
version-tag:
description: Python package version to release to PyPI (without 'v')
required: true
default: 4.14
dry-run:
description: Dry run
type: boolean
default: false
jobs:
linux:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
# Use old ubuntu for binary compatibility with older glibc
- runner: ubuntu-20.04
target: manylinux_2_28_x86_64
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
pip install uv
uv tool install build
uv tool install wheel
- name: Build app
run: |
bash build_reduce.sh ${{ inputs.reduce-release-tag }}
- name: Build python wheel
run: |
bash build_python.sh wheel ${{ inputs.version-tag }} ${{ matrix.platform.target }}
- uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Test wheel
run: |
uv venv
source .venv/bin/activate
uv pip install -r requirements_test.txt
uv pip install build_python/dist/*.whl
pytest
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheel-linux-${{ matrix.platform.target }}
path: build_python/dist/*.whl
macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
# Use the oldest version possible to maximize compatibility
- runner: macos-12
target: macosx_12_0_x86_64
- runner: macos-14
target: macosx_14_0_arm64
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
uname -a
pip install uv --break-system-packages
uv tool update-shell
uv tool install build
uv tool install wheel
brew install gnu-sed
- name: Build app
run: |
bash build_reduce.sh ${{ inputs.reduce-release-tag }}
- name: Build python wheel
run: |
export PATH="/Users/runner/.local/bin:$PATH"
bash build_python.sh wheel ${{ inputs.version-tag }} ${{ matrix.platform.target }}
- name: Test wheel
run: |
uv venv
source .venv/bin/activate
uv pip install -r requirements_test.txt
uv pip install build_python/dist/*.whl
pytest
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
path: build_python/dist/*.whl
name: wheel-macos-${{ matrix.platform.target }}
sdist:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
pip install uv --break-system-packages
uv tool install build
- name: Build sdist
run: |
bash build_python.sh sdist ${{ inputs.version-tag }}
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
path: build_python/dist/*.tar.gz
name: wheel-sdist
release:
name: Release
if: ${{ github.event.inputs.dry-run == 'false' }}
runs-on: ubuntu-24.04
needs: [linux, macos, sdist]
steps:
- uses: actions/download-artifact@v4
with:
path: dist
pattern: wheel-*
merge-multiple: true
- name: Build and upload to PyPI
run: |
pip install uv --break-system-packages
uv tool install twine
twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --non-interactive