Skip to content

Release

Release #20

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
linux:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# Ubuntu 22.04 (libc 2.35)
- os: ubuntu-22.04
target: x86_64
manylinux: manylinux_2_35
python-versions: '["3.11", "3.12"]'
# Ubuntu 24.04 (libc 2.38)
- os: ubuntu-24.04
target: x86_64
manylinux: manylinux_2_38
python-versions: '["3.11", "3.12"]'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache static OpenCV
id: cache-opencv
uses: actions/cache@v4
with:
path: third_party/opencv-static
key: opencv-static-4.12.0-no-itt-linux-${{ matrix.os }}-${{ runner.arch }}-${{ matrix.manylinux }}
- name: Install build dependencies
run: |
sudo apt-get update
# Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
sudo apt-get install -y clang libclang-dev llvm-dev cmake curl wget software-properties-common
# Add LLVM PPA for Ubuntu 22.04 to get LLVM 18
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
sudo apt-get update
fi
# Install LLVM 18 (available by default in Ubuntu 24.04)
sudo apt-get install -y llvm-18 llvm-18-dev llvm-18-tools libclang1-18 libclang-cpp18
# Set environment variables for LLVM 18
echo "LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/usr/bin/llvm-config-18" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# Verify the key files exist
ls -la /usr/lib/x86_64-linux-gnu/libclang.so
which llvm-config-18
- name: Build static OpenCV
if: steps.cache-opencv.outputs.cache-hit != 'true'
run: |
./scripts/build-opencv-static.sh
- name: Build wheels for multiple Python versions
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --no-default-features --features python-bindings,simd,opencv
sccache: 'false'
container: off
manylinux: ${{ matrix.manylinux }}
env:
# Use stable ABI for forward compatibility
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
# LLVM for opencv-rust bindings (from earlier install step)
LIBCLANG_PATH: /usr/lib/x86_64-linux-gnu
LLVM_CONFIG_PATH: /usr/bin/llvm-config-18
# OpenCV static linking configuration
OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
OPENCV_LINK_LIBS: static=opencv_world,static=stdc++
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.os }}-${{ matrix.target }}
path: dist
macos:
runs-on: macos-latest
strategy:
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Cache static OpenCV
id: cache-opencv
uses: actions/cache@v4
with:
path: third_party/opencv-static
key: opencv-static-4.12.0-no-itt-macos-${{ runner.os }}-${{ runner.arch }}
- name: Install build dependencies
run: |
# Install LLVM for opencv-rust bindings codegen (no need for system OpenCV anymore)
brew install llvm cmake
# Set up LLVM environment for opencv-rust bindings (keg-only installation)
echo "LIBCLANG_PATH=/opt/homebrew/opt/llvm/lib" >> $GITHUB_ENV
echo "LLVM_CONFIG_PATH=/opt/homebrew/opt/llvm/bin/llvm-config" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=/opt/homebrew/opt/llvm/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Build static OpenCV
if: steps.cache-opencv.outputs.cache-hit != 'true'
run: |
./scripts/build-opencv-static.sh
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter --no-default-features --features python-bindings,simd,opencv,metal
sccache: 'false'
env:
# Use stable ABI for forward compatibility
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: '1'
# OpenCV static linking configuration
OPENCV_INCLUDE_PATHS: ${{ github.workspace }}/third_party/opencv-static/include/opencv4
OPENCV_LINK_PATHS: ${{ github.workspace }}/third_party/opencv-static/lib
OPENCV_LINK_LIBS: static=opencv_world,framework=Accelerate,dylib=c++
OPENCV_DISABLE_PROBES: pkg_config,cmake,vcpkg,vcpkg_cmake
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: dist
sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: dist
release:
name: Release
runs-on: ubuntu-latest
needs: [linux, macos, sdist]
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: dist
- name: List built wheels
run: |
echo "Built wheels:"
ls -la dist/
echo "Wheel information:"
python -c "import zipfile; [print(f'{f}: {zipfile.ZipFile(f).namelist()[:3]}') for f in [f for f in __import__('os').listdir('dist') if f.endswith('.whl')]]"
- name: Publish to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}