minigdb 0.1.0

An embedded property-graph database in Rust with a GQL query language, RocksDB-backed ACID storage, graph algorithms, and Python bindings
Documentation
name: Release

# Triggered by pushing a version tag: git tag v0.2.1 && git push --tags
on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

env:
  FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"

jobs:
  # ── Build wheels for all supported platforms ─────────────────────────────
  build-wheels:
    name: Wheel — ${{ matrix.name }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Linux x86_64 — quay.io/pypa/manylinux_2_28_x86_64 (AlmaLinux 8).
          # librocksdb-sys needs libclang for bindgen; see before-script-linux below.
          - name: linux-x86_64
            os: ubuntu-latest
            target: x86_64
            manylinux: "2_28"
            qemu: false
            maturin-container: ""
            python-version: ""

          # Linux aarch64 — native ARM64 runner; no QEMU needed.
          # maturin-action auto-selects quay.io/pypa/manylinux_2_28_aarch64 container.
          - name: linux-aarch64
            os: ubuntu-22.04-arm
            target: aarch64
            manylinux: "2_28"
            qemu: false
            maturin-container: ""
            python-version: ""

          # macOS universal2 — fat wheel for Intel + Apple Silicon.
          # actions/setup-python pins Python 3.12 to avoid PyO3 0.22's ≤3.13 check;
          # PYO3_USE_ABI3_FORWARD_COMPATIBILITY is a fallback for the cross-compile part.
          - name: macos-universal
            os: macos-latest
            target: universal2-apple-darwin
            manylinux: ""
            qemu: false
            maturin-container: ""
            python-version: "3.12"

          # Windows x86_64.
          - name: windows-x86_64
            os: windows-latest
            target: x86_64
            manylinux: ""
            qemu: false
            maturin-container: ""
            python-version: ""

    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      # Required for linux-aarch64: registers QEMU binfmt handlers so Docker can
      # run the native aarch64 manylinux container on an x86_64 host.
      - uses: docker/setup-qemu-action@v3
        if: matrix.qemu
        with:
          platforms: aarch64

      # Pin Python on macOS to avoid PyO3 0.22's Python ≤ 3.13 version check.
      - uses: actions/setup-python@v5
        if: matrix.python-version != ''
        with:
          python-version: ${{ matrix.python-version }}

      - name: Build wheel
        uses: PyO3/maturin-action@v1
        with:
          target: ${{ matrix.target }}
          args: --release --out dist --features python
          manylinux: ${{ matrix.manylinux }}
          container: ${{ matrix.maturin-container }}
          # librocksdb-sys uses bindgen which requires libclang.
          # On AlmaLinux 8 (manylinux_2_28), clang installs libclang.so into a
          # versioned subdirectory (/usr/lib64/llvmN/lib/) that bindgen won't scan.
          # We install clang+clang-devel then symlink the library into /usr/lib64/
          # so bindgen finds it.  before-script-linux is ignored on macOS/Windows.
          before-script-linux: |
            yum install -y clang clang-devel
            LIBCLANG=$(find /usr/lib64 /usr/lib -name 'libclang.so*' -type f 2>/dev/null | sort | head -1)
            if [ -n "$LIBCLANG" ]; then
              ln -sf "$LIBCLANG" /usr/lib64/libclang.so
            fi
        env:
          # Suppress PyO3 max-version check on Windows (no Docker, env is forwarded).
          PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
          # RocksDB 8.10.0 uses C++17 aligned-allocation operators only available on
          # macOS 10.13+.  librocksdb-sys defaults to 10.12, which breaks the x86_64
          # slice of the universal2 cross-compile.  Ignored on Linux/Windows.
          MACOSX_DEPLOYMENT_TARGET: "10.13"

      - name: Upload wheel artifact
        uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.name }}
          path: dist/*.whl

  # ── Build source distribution (sdist) ────────────────────────────────────
  # Users on unsupported platforms can install from source with:
  #   pip install minigdb --no-binary minigdb
  # They need: Rust toolchain + cmake + C++ compiler.
  build-sdist:
    name: Source distribution
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build sdist
        uses: PyO3/maturin-action@v1
        with:
          command: sdist
          args: --out dist

      - name: Upload sdist artifact
        uses: actions/upload-artifact@v4
        with:
          name: sdist
          path: dist/*.tar.gz

  # ── Publish to PyPI ───────────────────────────────────────────────────────
  # Uses OIDC trusted publishing — no API token secret required.
  publish:
    name: Publish to PyPI
    needs: [build-wheels, build-sdist]
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      id-token: write   # required for OIDC trusted publishing

    steps:
      - name: Download all wheel artifacts
        uses: actions/download-artifact@v4
        with:
          pattern: "wheels-*"
          merge-multiple: true
          path: dist

      - name: Download sdist artifact
        uses: actions/download-artifact@v4
        with:
          name: sdist
          path: dist

      - name: Publish to PyPI
        uses: PyO3/maturin-action@v1
        with:
          command: upload
          args: --non-interactive --skip-existing dist/**

  # ── Create GitHub Release ─────────────────────────────────────────────────
  github-release:
    name: GitHub Release
    needs: [publish]
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    permissions:
      contents: write   # required to create releases

    steps:
      - name: Download all wheel artifacts
        uses: actions/download-artifact@v4
        with:
          pattern: "wheels-*"
          merge-multiple: true
          path: dist

      - name: Download sdist artifact
        uses: actions/download-artifact@v4
        with:
          name: sdist
          path: dist

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: dist/**
          generate_release_notes: true