Merge pull request #97 from iscgar/release_gil_for_bytes_haystack #200
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: CI | |
on: | |
push: | |
branches: ["main"] | |
tags: | |
- "*" | |
pull_request: | |
branches: ["main"] | |
env: | |
# Give nice tracebacks on segfaults. | |
PYTHONFAULTHANDLER: "true" | |
MATURIN_VERSION: "1.2.0" | |
jobs: | |
tests: | |
name: "${{ matrix.os }}: Python ${{ matrix.python-version }}" | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
os: ["ubuntu-20.04", "macos-11", "windows-latest"] | |
env: | |
MATURIN_EXTRA: "" | |
runs-on: "${{ matrix.os }}" | |
steps: | |
- uses: "actions/checkout@v4" | |
with: | |
# We need tags to get the correct code version: | |
fetch-depth: 0 | |
- uses: "actions/setup-python@v5" | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- uses: "dtolnay/rust-toolchain@stable" | |
- name: "Compile" | |
run: | | |
pip install -r requirements-dev.txt | |
pip install . | |
- name: "Tests" | |
run: | | |
flake8 pysrc tests | |
mypy --strict pysrc tests | |
black --check pysrc tests | |
pytest tests | |
- name: "Enable universal2 on Python >= 3.9 on macOS" | |
if: ${{ startsWith(matrix.os, 'macos') && matrix.python-version != '3.8' }} | |
run: | | |
rustup target add aarch64-apple-darwin | |
echo "MATURIN_EXTRA=--target=universal2-apple-darwin" >> $GITHUB_ENV | |
- name: "Wheels" | |
uses: messense/maturin-action@v1 | |
with: | |
maturin-version: "${{ env.MATURIN_VERSION }}" | |
command: build | |
manylinux: auto | |
args: --release --out target/wheels/ -i python${{ matrix.python-version }} ${{ env.MATURIN_EXTRA }} | |
- name: "sdist" | |
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.python-version == '3.9' }} | |
run: | | |
pip install maturin==${{ env.MATURIN_VERSION }} | |
maturin sdist | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Wheels | |
path: target/wheels/*.whl | |
- name: Archive production artifacts 2 | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Wheels | |
path: target/wheels/ahocorasick*.tar.gz | |
cross: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Build wheels | |
uses: messense/maturin-action@v1 | |
with: | |
maturin-version: "${{ env.MATURIN_VERSION }}" | |
target: aarch64-unknown-linux-gnu | |
manylinux: auto | |
args: --release --out target/wheels/ -i python${{ matrix.python-version }} | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Wheels | |
path: target/wheels/*.whl | |
publish: | |
needs: ['cross', 'tests'] | |
environment: 'release' | |
runs-on: ubuntu-latest | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing | |
id-token: write | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: Wheels | |
path: dist/ | |
- run: | | |
# Remove badly named wheels: | |
rm dist/*-linux_*.whl | |
# Show what's left: | |
ls -R dist/ | |
- name: Publish package distributions to PyPI (if tagged) | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
packages_dir: dist/ |