Build and publish wheels on PyPI #73
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 and publish wheels on PyPI | |
on: | |
release: | |
types: [created] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
linux-x86-wheels: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
container: | |
- "quay.io/pypa/musllinux_1_2_x86_64" | |
- "quay.io/pypa/manylinux_2_28_x86_64" | |
container: ${{ matrix.container }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheels | |
run: | | |
bash .github/workflows/build-wheels.sh | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: wheelhouse | |
if-no-files-found: error | |
linux-aarch-wheels: | |
runs-on: ubuntu-lates | |
strategy: | |
matrix: | |
container: | |
- "quay.io/pypa/musllinux_1_2_aarch64" | |
- "quay.io/pypa/manylinux_2_28_aarch64" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install QEMU | |
run: | | |
docker run --privileged --rm tonistiigi/binfmt --install arm64 | |
- name: Build wheels | |
run: | | |
docker run --platform linux/arm64 --workdir /src -v ${PWD}:/src ${{ matrix.container }} /bin/bash .github/workflows/build-wheels.sh | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: wheelhouse | |
if-no-files-found: error | |
osx-wheels: | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
default: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build wheels | |
run: | | |
rustup target add x86_64-apple-darwin | |
rustup target add aarch64-apple-darwin | |
python3 -m pip install -r requirements.txt -r requirements-dev.txt | |
maturin build --release --strip --target universal2-apple-darwin | |
python3 -m pip install kmedoids --no-index --find-links target/wheels | |
cd tests && python3 -m unittest discover && cd .. | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: target/wheels | |
if-no-files-found: error | |
windows-wheels: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
default: true | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build wheels | |
run: | | |
python -m pip install -r requirements.txt -r requirements-dev.txt | |
maturin build --release --strip | |
python -m pip install kmedoids --no-index --find-links target/wheels | |
cd tests && python -m unittest discover && cd .. | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: target/wheels | |
if-no-files-found: error | |
upload-wheels: | |
name: Upload wheels to PyPI | |
needs: [linux-x86-wheels, linux-aarch-wheels, osx-wheels, windows-wheels] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Collect artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
path: wheels/ | |
- name: List contents | |
run: ls -R | |
working-directory: wheels/ | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} | |
packages_dir: wheels/ | |
skip_existing: true | |
verbose: true |