yass-2 2.0.0

Yet another string similarity library
Documentation
name: CI

on:
  push:
  pull_request:

jobs:
  build:
    strategy:
      matrix:
        python: ["3.8", "3.9", "3.10", "3.11"]
        platform: ["ubuntu-22.04", "macos-12", "windows-2022"]
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}
      - name: Cache Rust target directory
        uses: actions/cache@v3
        with:
          key: ${{ runner.os }}
          path: |
            ~/.cargo  
            target
      - name: Run test
        if: matrix.python == '3.8'
        run: cargo test --no-default-features --features pyo3/auto-initialize
      - uses: messense/maturin-action@v1
        env:
          MACOSX_DEPLOYMENT_TARGET: 10.14
        with:
          command: build
          args: --release ${{ startsWith(matrix.platform, 'ubuntu') && startsWith(matrix.python, '3.8') && '--sdist' || '' }} -o dist -i python ${{ startsWith(matrix.platform, 'macos') && '--target universal2-apple-darwin' || '' }}
      - name: Run test
        if: matrix.python == '3.8' && !startsWith(matrix.platform, 'windows')
        run: |
          python -c "import subprocess, glob, os; file = glob.glob(os.path.join('dist', '*cp38*.whl'))[0]; subprocess.check_output(['pip', 'install', file])"
          pip install pytest
          mv strsim strsim2
          pytest -xs tests/
      - name: Upload wheels
        uses: actions/upload-artifact@v2
        with:
          name: wheels
          path: dist

  build-manylinux:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Cache Rust target directory
        uses: actions/cache@v3
        with:
          key: ${{ runner.os }}-manylinux
          path: target
      - name: Build wheels
        run: |
          docker run --rm -w /project -v $(pwd):/project \
            -e EXTRA_PATH=/opt/python/cp38-cp38/bin \
            -e PYTHON_HOMES=/opt/python \
            -e CARGO_NET_GIT_FETCH_WITH_CLI=false \
            quay.io/pypa/manylinux2014_x86_64:latest \
            bash /project/.github/workflows/build.sh -t x86_64-unknown-linux-gnu
      - name: Upload wheels
        uses: actions/upload-artifact@v2
        with:
          name: wheels
          path: dist

  release-crate:
    name: Release Crates.io
    runs-on: ubuntu-22.04
    if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/dev-ci')
    needs: [build, build-manylinux]
    steps:
      - uses: actions/checkout@v3
      - name: Publish to Crates
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
        run: |
          cargo publish --dry-run
          cargo publish --no-verify || echo 'crate is already published'

  release-pypi:
    name: Release PyPI.org
    runs-on: ubuntu-22.04
    if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/dev-ci')
    needs: [build, build-manylinux]
    steps:
      - uses: actions/download-artifact@v2
        with:
          name: wheels
      - name: Publish to PyPI
        uses: messense/maturin-action@v1
        env:
          MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
        with:
          command: upload
          args: --skip-existing *