sqlite-graphrag 1.0.0

Local GraphRAG memory for LLMs in a single SQLite file
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  validate:
    name: Validate (cargo publish dry-run)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo publish --dry-run --allow-dirty

  build-matrix:
    name: Build ${{ matrix.target }}
    needs: validate
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            use-cross: false
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            use-cross: false
            musl: true
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            use-cross: true
          - target: aarch64-unknown-linux-musl
            os: ubuntu-latest
            use-cross: true
          - target: x86_64-apple-darwin
            os: macos-latest
            use-cross: false
          - target: aarch64-apple-darwin
            os: macos-latest
            use-cross: false
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            use-cross: false
          - target: aarch64-pc-windows-msvc
            os: windows-latest
            use-cross: false
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

      - name: Install musl tools
        if: matrix.musl == true
        run: sudo apt-get update && sudo apt-get install -y musl-tools

      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

      - name: Install cross
        if: matrix.use-cross == true
        run: cargo install cross --locked

      - name: Build with cross
        if: matrix.use-cross == true
        run: cross build --release --target ${{ matrix.target }}

      - name: Build with cargo
        if: matrix.use-cross != true
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package (Unix)
        if: runner.os != 'Windows'
        run: |
          bin="sqlite-graphrag"
          pkg_name="sqlite-graphrag-${{ github.ref_name }}-${{ matrix.target }}"
          mkdir -p "$pkg_name"
          cp "target/${{ matrix.target }}/release/$bin" "$pkg_name/"
          cp README.md CHANGELOG.md "$pkg_name/"
          tar czf "$pkg_name.tar.gz" "$pkg_name"
          shasum -a 256 "$pkg_name.tar.gz" > "$pkg_name.tar.gz.sha256"

      - name: Package (Windows)
        if: runner.os == 'Windows'
        shell: bash
        run: |
          bin="sqlite-graphrag.exe"
          pkg_name="sqlite-graphrag-${{ github.ref_name }}-${{ matrix.target }}"
          mkdir -p "$pkg_name"
          cp "target/${{ matrix.target }}/release/$bin" "$pkg_name/"
          cp README.md CHANGELOG.md "$pkg_name/"
          7z a "$pkg_name.zip" "$pkg_name"
          certutil -hashfile "$pkg_name.zip" SHA256 > "$pkg_name.zip.sha256"

      - uses: actions/upload-artifact@v4
        with:
          name: sqlite-graphrag-${{ matrix.target }}
          path: |
            sqlite-graphrag-*.tar.gz
            sqlite-graphrag-*.tar.gz.sha256
            sqlite-graphrag-*.zip
            sqlite-graphrag-*.zip.sha256

  macos-universal:
    name: macOS Universal Binary
    needs: build-matrix
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/download-artifact@v4
        with:
          name: sqlite-graphrag-x86_64-apple-darwin
          path: x86_64/

      - uses: actions/download-artifact@v4
        with:
          name: sqlite-graphrag-aarch64-apple-darwin
          path: aarch64/

      - name: Extract binaries and lipo
        run: |
          cd x86_64
          tar xzf sqlite-graphrag-*-x86_64-apple-darwin.tar.gz
          cd ../aarch64
          tar xzf sqlite-graphrag-*-aarch64-apple-darwin.tar.gz
          cd ..
          mkdir -p sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin
          lipo -create \
            x86_64/sqlite-graphrag-*/sqlite-graphrag \
            aarch64/sqlite-graphrag-*/sqlite-graphrag \
            -output sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin/sqlite-graphrag
          cp README.md CHANGELOG.md sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin/
          tar czf sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin.tar.gz \
            sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin
          shasum -a 256 sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin.tar.gz \
            > sqlite-graphrag-${{ github.ref_name }}-universal-apple-darwin.tar.gz.sha256

      - uses: actions/upload-artifact@v4
        with:
          name: sqlite-graphrag-universal-apple-darwin
          path: |
            sqlite-graphrag-*-universal-apple-darwin.tar.gz
            sqlite-graphrag-*-universal-apple-darwin.tar.gz.sha256

  publish-github-release:
    name: Publish GitHub Release
    needs: [build-matrix, macos-universal]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

      - uses: actions/download-artifact@v4
        with:
          path: artifacts/

      - name: Collect release assets
        run: |
          mkdir -p release
          find artifacts/ -type f \( -name "*.tar.gz" -o -name "*.zip" -o -name "*.sha256" \) -exec cp {} release/ \;
          cd release
          ls -la

      - name: Compute consolidated SHA256SUMS
        run: |
          cd release
          rm -f SHA256SUMS.txt
          for f in *.tar.gz *.zip; do
            [ -e "$f" ] || continue
            shasum -a 256 "$f" >> SHA256SUMS.txt
          done
          cat SHA256SUMS.txt

      - name: Create release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          gh release create "${{ github.ref_name }}" \
            --title "${{ github.ref_name }}" \
            --notes-file CHANGELOG.md \
            --verify-tag \
            release/*

  publish-crates-io:
    name: crates.io publish is manual
    needs: publish-github-release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: |
          echo "crates.io publication is intentionally manual for sqlite-graphrag v1.0.0"
          echo "run 'cargo login' once locally and then 'cargo publish' when you are ready"