Files
kmeans_rs/.github/workflows/CI.yml
T

151 lines
4.6 KiB
YAML
Raw Normal View History

2026-04-16 16:26:53 +02:00
name: CI
on:
push:
branches:
- main
tags:
- '*'
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
2026-04-16 19:18:53 +02:00
wheels:
2026-04-17 13:38:45 +02:00
runs-on: ubuntu-latest
2026-04-16 16:26:53 +02:00
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
2026-04-16 18:26:18 +02:00
2026-04-17 14:27:05 +02:00
- name: Restore cache
uses: actions/cache/restore@v4
2026-04-16 18:02:50 +02:00
with:
path: |
~/.cache/pip
~/.cache/pip-wheel
~/.cache/sccache
2026-04-17 13:38:45 +02:00
~/.cache/cargo-xwin
2026-04-17 13:52:57 +02:00
~/.cargo
~/.osxcross
2026-04-17 14:48:30 +02:00
~/.apt
2026-04-17 13:52:57 +02:00
key: cache-ubuntu-maturin-cross-compile
2026-04-16 18:02:50 +02:00
2026-04-17 14:48:30 +02:00
- name: Install llvm
run: |
if ! command -v llvm-dlltool >/dev/null 2>&1; then
2026-04-17 14:52:53 +02:00
mkdir -p ~/.apt/archives/partial
2026-04-17 14:57:19 +02:00
cd
cd .apt
tree
2026-04-17 14:52:21 +02:00
sudo apt -o Dir::Cache="~/.apt" update
sudo apt -o Dir::Cache="~/.apt" install -y llvm
2026-04-17 14:48:30 +02:00
fi
shell: bash
2026-04-17 13:58:53 +02:00
2026-04-17 13:52:57 +02:00
- name: Install Rust
2026-04-16 17:39:35 +02:00
run: |
2026-04-17 14:11:36 +02:00
export PATH="$HOME/.cargo/bin:$PATH"
2026-04-16 18:02:50 +02:00
if ! command -v rustc >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2026-04-17 13:52:57 +02:00
else
rustup update
2026-04-16 18:02:50 +02:00
fi
shell: bash
- name: Install sccache and maturin
run: |
2026-04-17 14:11:36 +02:00
export PATH="$HOME/.cargo/bin:$PATH"
2026-04-16 18:02:50 +02:00
python -m pip install --upgrade pip
2026-04-17 13:05:06 +02:00
pip install maturin ziglang
2026-04-16 18:02:50 +02:00
if ! command -v sccache >/dev/null 2>&1; then
cargo install sccache || pip install sccache
2026-04-17 13:38:45 +02:00
fi
shell: bash
- name: Install xwin
run: |
2026-04-17 14:11:36 +02:00
export PATH="$HOME/.cargo/bin:$PATH"
2026-04-17 13:38:45 +02:00
if ! command -v cargo-xwin >/dev/null 2>&1; then
2026-04-16 19:11:53 +02:00
cargo install cargo-xwin || pip install cargo-xwin
2026-04-17 13:38:45 +02:00
cargo xwin cache xwin
2026-04-16 18:02:50 +02:00
fi
shell: bash
2026-04-17 13:05:06 +02:00
- name: Install osxcross
run: |
2026-04-17 14:11:36 +02:00
export PATH="$HOME/.osxcross/bin:$PATH"
2026-04-17 13:05:06 +02:00
if ! command -v osxcross >/dev/null 2>&1; then
wget https://nextcloud.wimpomp.nl/s/DcrTwoP3SeY7DQF/download -O osxcross.tar.gz
2026-04-17 13:52:57 +02:00
tar -xzf osxcross.tar.gz -C ~/
mv ~/osxcross ~/.osxcross
2026-04-17 13:05:06 +02:00
fi
2026-04-16 16:26:53 +02:00
- name: Build wheels
2026-04-16 17:37:08 +02:00
run: |
2026-04-17 14:11:36 +02:00
export PATH="$HOME/.cargo/bin:$HOME/.osxcross/bin:$PATH"
2026-04-16 18:36:54 +02:00
maturin sdist --out dist
2026-04-17 13:05:06 +02:00
rustup default nightly
2026-04-17 14:27:05 +02:00
2026-04-17 13:05:06 +02:00
rustup target add x86_64-unknown-linux-gnu --toolchain nightly
maturin build --release --out dist --target x86_64-unknown-linux-gnu
2026-04-17 13:23:31 +02:00
rustup target add aarch64-unknown-linux-gnu --toolchain nightly
maturin build --release --out dist --target aarch64-unknown-linux-gnu --zig
2026-04-16 19:18:53 +02:00
rustup target add x86_64-pc-windows-msvc --toolchain nightly
maturin build --release --out dist --target x86_64-pc-windows-msvc
2026-04-17 13:23:31 +02:00
rustup target add aarch64-pc-windows-msvc --toolchain nightly
maturin build --release --out dist --target aarch64-pc-windows-msvc
2026-04-17 13:05:06 +02:00
rustup target add x86_64-apple-darwin --toolchain nightly
2026-04-17 13:23:31 +02:00
maturin build --release --out dist --target x86_64-apple-darwin --zig
rustup target add aarch64-apple-darwin --toolchain nightly
maturin build --release --out dist --target aarch64-apple-darwin --zig
2026-04-16 18:18:04 +02:00
2026-04-17 14:27:05 +02:00
- name: Store cache
uses: actions/cache/save@v4
with:
path: |
~/.cache/pip
~/.cache/pip-wheel
~/.cache/sccache
~/.cache/cargo-xwin
~/.cargo
~/.osxcross
2026-04-17 14:48:30 +02:00
~/.apt
2026-04-17 14:27:05 +02:00
key: cache-ubuntu-maturin-cross-compile
2026-04-16 16:26:53 +02:00
- name: Upload wheels
2026-04-16 18:02:50 +02:00
uses: actions/upload-artifact@v3.2.2
2026-04-16 16:26:53 +02:00
with:
2026-04-16 18:50:24 +02:00
path: dist/kmeans-*
2026-04-16 16:26:53 +02:00
release:
name: Release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
2026-04-16 19:18:53 +02:00
needs: [wheels]
2026-04-16 16:26:53 +02:00
permissions:
# Use to sign the release artifacts
id-token: write
# Used to upload release artifacts
contents: write
# Used to generate artifact attestation
attestations: write
steps:
- uses: actions/download-artifact@v4
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: 'wheels-*/*'
- name: Publish to PyPI
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*