readcon-db 0.1.4

Mmap-backed CON frame corpus (Heed/LMDB), xxHash exact match, multi-language FFI
Documentation
name: Python wheels

on:
  push:
    tags:
      - 'v*'
  pull_request:
    paths:
      - 'src/**'
      - 'Cargo.toml'
      - 'Cargo.lock'
      - 'python/**'
      - '.github/workflows/python-wheels.yml'
  workflow_dispatch:

concurrency:
  group: python-wheels-${{ github.ref }}
  cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}

permissions:
  contents: read

env:
  CARGO_HTTP_MULTIPLEXING: "false"
  CARGO_NET_RETRY: "10"
  CARGO_HTTP_TIMEOUT: "120"
  CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER: "cc"

jobs:
  sdist:
    name: Build sdist
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: python
    steps:
      - uses: actions/checkout@v4
      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out ../dist
          working-directory: python
      - name: Validate sdist
        run: pipx run twine check --strict ../dist/*
        working-directory: python
      - uses: actions/upload-artifact@v4
        with:
          name: sdist
          path: dist/*.tar.gz
          if-no-files-found: error

  wheels:
    name: Wheel (${{ matrix.os }}, ${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-24.04
            target: x86_64
          - os: ubuntu-24.04-arm
            target: aarch64
          - os: macos-15-intel
            target: x86_64
          - os: macos-15
            target: aarch64
          - os: windows-2022
            target: x86_64
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Build wheels
        env:
          RUSTFLAGS: ${{ runner.os == 'Linux' && '-C link-arg=-fuse-ld=bfd' || '' }}
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          manylinux: auto
          working-directory: python
          args: --release --out ../dist --features python --find-interpreter
          docker-options: >-
            -e CARGO_HTTP_MULTIPLEXING=false
            -e CARGO_NET_RETRY=10
            -e CARGO_HTTP_TIMEOUT=120
      - name: Validate wheels
        if: matrix.target != 'aarch64' || runner.os != 'Linux'
        run: pipx run twine check --strict dist/*
      - uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.os }}-${{ matrix.target }}
          path: dist/*.whl
          if-no-files-found: error

  github-release:
    name: Attach wheels to GitHub Release
    needs: [sdist, wheels]
    if: ${{ always() && startsWith(github.ref, 'refs/tags/v') && needs.sdist.result == 'success' }}
    runs-on: ubuntu-24.04
    permissions:
      contents: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: '{sdist,wheels-*}'
          merge-multiple: true
          path: dist/
      - name: Upload to GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: dist/*
          fail_on_unmatched_files: false

  publish:
    name: Publish to PyPI
    needs: [sdist, wheels]
    runs-on: ubuntu-latest
    if: ${{ always() && startsWith(github.ref, 'refs/tags/v') && needs.sdist.result == 'success' }}
    environment:
      name: pypi
      url: https://pypi.org/p/readcon-db
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v4
        with:
          pattern: '{sdist,wheels-*}'
          merge-multiple: true
          path: dist/
      - name: List artifacts
        run: ls -la dist/
      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          skip-existing: true