A fast, helpful, and open-source document parser
make workflows make sense
Logan Markewichf30790f8f105
diff --git a/.github/workflows/ci-node.yml b/.github/workflows/ci-node.ymlnew file mode 100644index 0000000..9f453a5--- /dev/null+++ b/.github/workflows/ci-node.yml@@ -0,0 +1,174 @@+name: CI - Node Bindings++on:+ push:+ branches: [main]+ paths:+ - 'crates/**'+ - 'packages/node/**'+ - '.github/workflows/ci-node.yml'+ pull_request:+ branches: [main]+ paths:+ - 'crates/**'+ - 'packages/node/**'+ - '.github/workflows/ci-node.yml'++env:+ CARGO_TERM_COLOR: always+ PDFIUM_RELEASE_TAG: chromium/7827++jobs:+ build:+ strategy:+ fail-fast: false+ matrix:+ include:+ - os: macos-latest+ target: aarch64-apple-darwin+ node-arch: darwin-arm64+ pdfium-dylib: libpdfium.dylib++ - os: macos-13+ target: x86_64-apple-darwin+ node-arch: darwin-x64+ pdfium-dylib: libpdfium.dylib++ - os: ubuntu-latest+ target: x86_64-unknown-linux-gnu+ node-arch: linux-x64-gnu+ pdfium-dylib: libpdfium.so++ - os: ubuntu-latest+ target: aarch64-unknown-linux-gnu+ node-arch: linux-arm64-gnu+ pdfium-dylib: libpdfium.so+ use-cross: true++ - os: windows-latest+ target: x86_64-pc-windows-msvc+ node-arch: win32-x64-msvc+ pdfium-dylib: pdfium.dll++ runs-on: ${{ matrix.os }}+ name: Build ${{ matrix.node-arch }}++ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-node@v4+ with:+ node-version: 20++ - uses: dtolnay/rust-toolchain@stable+ with:+ targets: ${{ matrix.target }}++ - name: Install cross-compilation tools (Linux ARM64)+ if: matrix.use-cross+ run: |+ sudo apt-get update+ sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu++ - uses: actions/cache@v4+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ ~/.cache/pdfium-rs+ ~/Library/Caches/pdfium-rs+ target+ key: ${{ runner.os }}-${{ matrix.target }}-cargo-node-${{ hashFiles('**/Cargo.lock') }}++ - name: Install dependencies+ working-directory: packages/node+ run: npm ci++ - name: Build native module+ working-directory: packages/node+ run: npx napi build --cargo-cwd ../../crates/liteparse-napi --platform --release --js false --dts native.d.ts --target ${{ matrix.target }} .++ - name: Copy pdfium dylib (Unix)+ if: runner.os != 'Windows'+ working-directory: packages/node+ run: bash scripts/copy-pdfium.sh .++ - name: Copy pdfium dylib (Windows)+ if: runner.os == 'Windows'+ working-directory: packages/node+ shell: pwsh+ run: |+ $cacheBase = "$env:LOCALAPPDATA\pdfium-rs"+ if (-not (Test-Path $cacheBase)) {+ $cacheBase = "$env:USERPROFILE\.cache\pdfium-rs"+ }+ $dll = Get-ChildItem -Path $cacheBase -Recurse -Filter "pdfium.dll" | Select-Object -First 1+ if ($dll) {+ Copy-Item $dll.FullName -Destination ".\pdfium.dll"+ Write-Host "Copied $($dll.FullName) -> .\pdfium.dll"+ } else {+ Write-Error "Could not find pdfium.dll in cache"+ exit 1+ }++ - name: Build TypeScript+ working-directory: packages/node+ run: npx tsc++ - name: Upload artifacts+ uses: actions/upload-artifact@v4+ with:+ name: bindings-${{ matrix.node-arch }}+ path: |+ packages/node/*.node+ packages/node/${{ matrix.pdfium-dylib }}+ if-no-files-found: error++ test:+ needs: build+ strategy:+ fail-fast: false+ matrix:+ include:+ - os: macos-latest+ node-arch: darwin-arm64+ - os: macos-13+ node-arch: darwin-x64+ - os: ubuntu-latest+ node-arch: linux-x64-gnu+ - os: windows-latest+ node-arch: win32-x64-msvc+ runs-on: ${{ matrix.os }}+ name: Test ${{ matrix.node-arch }}++ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-node@v4+ with:+ node-version: 20++ - name: Install dependencies+ working-directory: packages/node+ run: npm ci++ - name: Download artifacts+ uses: actions/download-artifact@v4+ with:+ name: bindings-${{ matrix.node-arch }}+ path: packages/node++ - name: Build TypeScript+ working-directory: packages/node+ run: npx tsc++ - name: Smoke test+ working-directory: packages/node+ run: |+ node -e "+ import('./dist/lib.js').then(async ({ LiteParse }) => {+ const p = new LiteParse({ ocrEnabled: false, quiet: true });+ console.log('Config:', JSON.stringify(p.getConfig()));+ console.log('Native module loaded successfully');+ });+ "diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/ci-python.ymlsimilarity index 89%rename from .github/workflows/python-bindings.ymlrename to .github/workflows/ci-python.ymlindex 5828475..2ff5cb5 100644--- a/.github/workflows/python-bindings.yml+++ b/.github/workflows/ci-python.yml@@ -1,14 +1,22 @@-name: Python Bindings+name: CI - Python Bindingson:push:branches: [main]- tags: ['v*']+ paths:+ - 'crates/**'+ - 'packages/python/**'+ - '.github/workflows/ci-python.yml'pull_request:branches: [main]+ paths:+ - 'crates/**'+ - 'packages/python/**'+ - '.github/workflows/ci-python.yml'env:CARGO_TERM_COLOR: always+ PDFIUM_RELEASE_TAG: chromium/7827jobs:build:@@ -67,7 +75,6 @@ jobs:manylinux: autoworking-directory: packages/pythonbefore-script-linux: |- # Install build deps inside the manylinux containerif command -v yum &> /dev/null; thenyum install -y clang-devel tesseract-devel leptonica-devel || trueelif command -v apt-get &> /dev/null; then@@ -104,7 +111,6 @@ jobs:working-directory: packages/pythonshell: pwshrun: |- # Find pdfium.dll in the build cache$cacheBase = "$env:LOCALAPPDATA\pdfium-rs"if (-not (Test-Path $cacheBase)) {$cacheBase = "$env:USERPROFILE\.cache\pdfium-rs"@@ -139,7 +145,6 @@ jobs:path: packages/python/dist/*.whlif-no-files-found: error- # Build source distributionsdist:runs-on: ubuntu-lateststeps:@@ -159,7 +164,6 @@ jobs:path: packages/python/dist/*.tar.gzif-no-files-found: error- # Test the built wheels on native platformstest:needs: buildstrategy:@@ -248,31 +252,3 @@ jobs:lit --versionlit parse demo/docs/apple-10q-q3-2025.pdf --no-ocr --max-pages 1 -q | head -5echo "CLI test passed"-- # Publish to PyPI on version tags- publish:- if: startsWith(github.ref, 'refs/tags/v')- needs: test- runs-on: ubuntu-latest- name: Publish to PyPI- permissions:- id-token: write-- steps:- - name: Download all wheels- uses: actions/download-artifact@v4- with:- pattern: wheels-*- path: dist- merge-multiple: true-- - name: Download sdist- uses: actions/download-artifact@v4- with:- name: sdist- path: dist-- - name: Publish to PyPI- uses: pypa/gh-action-pypi-publish@release/v1- with:- packages-dir: dist/diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 31449d2..d92af80 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -8,6 +8,7 @@ on:env:CARGO_TERM_COLOR: always+ PDFIUM_RELEASE_TAG: chromium/7827jobs:fmt:@@ -78,12 +79,19 @@ jobs:~/.cargo/git~/.cache/pdfium-rs~/Library/Caches/pdfium-rs+ ${{ runner.os == 'Windows' && format('{0}\pdfium-rs', env.LOCALAPPDATA) || '' }}targetkey: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}- run: cargo build --all-targets- run: cargo test --all+ - name: CLI smoke test+ if: runner.os != 'Windows'+ run: |+ ./target/debug/lit --version+ ./target/debug/lit parse demo/docs/apple-10q-q3-2025.pdf --no-ocr --max-pages 1 -q | head -5+# Test that docker buildsbuild-docker-image:runs-on: ubuntu-latestdiff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.ymldeleted file mode 100644index 6367b8b..0000000--- a/.github/workflows/docker-image.yml+++ /dev/null@@ -1,125 +0,0 @@-name: Build and Publish Docker Image--on:- push:- tags: ["v*.*.*"]- branches: [main]--env:- REGISTRY: ghcr.io- IMAGE_NAME_BASE: run-llama/liteparse-base- IMAGE_NAME: run-llama/liteparse--jobs:- build-and-publish-base-docker-image:- runs-on: ubuntu-latest- permissions:- contents: read- packages: write- id-token: write-- steps:- - name: Checkout repository- uses: actions/checkout@v4-- - name: Install cosign- if: github.event_name != 'pull_request'- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0- with:- cosign-release: "v2.2.4"-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0-- - name: Set up QEMU- uses: docker/setup-qemu-action@v4-- - name: Log into registry ${{ env.REGISTRY }}- if: github.event_name != 'pull_request'- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0- with:- registry: ${{ env.REGISTRY }}- username: ${{ github.actor }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Extract Docker metadata- id: meta- uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0- with:- images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BASE }}-- - name: Build and push Docker image- id: build-and-push- uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0- with:- platforms: linux/amd64,linux/arm64- context: .- push: ${{ github.event_name != 'pull_request' }}- tags: ${{ steps.meta.outputs.tags }}- labels: ${{ steps.meta.outputs.labels }}- cache-from: type=gha- cache-to: type=gha,mode=max-- - name: Sign the published Docker image- if: ${{ github.event_name != 'pull_request' }}- env:- TAGS: ${{ steps.meta.outputs.tags }}- DIGEST: ${{ steps.build-and-push.outputs.digest }}- run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}-- build-and-publish-full-docker-image:- runs-on: ubuntu-latest- permissions:- contents: read- packages: write- id-token: write-- steps:- - name: Checkout repository- uses: actions/checkout@v4-- - name: Install cosign- if: github.event_name != 'pull_request'- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0- with:- cosign-release: "v2.2.4"-- - name: Set up Docker Buildx- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0-- - name: Set up QEMU- uses: docker/setup-qemu-action@v4-- - name: Log into registry ${{ env.REGISTRY }}- if: github.event_name != 'pull_request'- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0- with:- registry: ${{ env.REGISTRY }}- username: ${{ github.actor }}- password: ${{ secrets.GITHUB_TOKEN }}-- - name: Extract Docker metadata- id: meta- uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0- with:- images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-- - name: Build and push Docker image- id: build-and-push- uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0- with:- platforms: linux/amd64,linux/arm64- context: .- file: full.Dockerfile- push: ${{ github.event_name != 'pull_request' }}- tags: ${{ steps.meta.outputs.tags }}- labels: ${{ steps.meta.outputs.labels }}- cache-from: type=gha- cache-to: type=gha,mode=max-- - name: Sign the published Docker image- if: ${{ github.event_name != 'pull_request' }}- env:- TAGS: ${{ steps.meta.outputs.tags }}- DIGEST: ${{ steps.build-and-push.outputs.digest }}- run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}diff --git a/.github/workflows/e2e-output.yml b/.github/workflows/e2e-output.ymlindex 0929927..c9f0ff8 100644--- a/.github/workflows/e2e-output.yml+++ b/.github/workflows/e2e-output.yml@@ -11,6 +11,9 @@ permissions:contents: readpull-requests: write+env:+ PDFIUM_RELEASE_TAG: chromium/7827+jobs:compare-outputs:runs-on: ubuntu-latestdiff --git a/.github/workflows/release.yml b/.github/workflows/release-crates.ymlsimilarity index 58%rename from .github/workflows/release.ymlrename to .github/workflows/release-crates.ymlindex a2ddcc0..2901f81 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release-crates.yml@@ -1,17 +1,42 @@-name: Release+name: Release - Crates & CLIon:- push:- tags: ["v*.*.*"]+ workflow_dispatch:+ inputs:+ version:+ description: 'Version to release (e.g. 2.1.0)'+ required: true+ type: string+ dry-run:+ description: 'Dry run (build but do not publish)'+ type: boolean+ default: falsepermissions:contents: write+ actions: writeenv:CARGO_TERM_COLOR: always+ PDFIUM_RELEASE_TAG: chromium/7827jobs:+ validate:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - name: Validate version+ run: |+ CARGO_VERSION=$(grep '^version' crates/liteparse/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')+ if [ "$CARGO_VERSION" != "${{ inputs.version }}" ]; then+ echo "::error::Version mismatch: crates/liteparse/Cargo.toml has $CARGO_VERSION, expected ${{ inputs.version }}"+ exit 1+ fi+ echo "Version validated: ${{ inputs.version }}"+publish-crates:+ needs: validate+ if: ${{ !inputs.dry-run }}runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4@@ -39,6 +64,7 @@ jobs:CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}build-binaries:+ needs: validatestrategy:matrix:include:@@ -48,8 +74,9 @@ jobs:- target: aarch64-unknown-linux-gnuos: ubuntu-latestartifact: lit-linux-arm64+ use-cross: true- target: x86_64-apple-darwin- os: macos-latest+ os: macos-13artifact: lit-darwin-x64- target: aarch64-apple-darwinos: macos-latest@@ -60,23 +87,21 @@ jobs:steps:- uses: actions/checkout@v4+ - uses: dtolnay/rust-toolchain@stable+ with:+ targets: ${{ matrix.target }}+- name: Install system dependencies (Linux native)- if: runner.os == 'Linux' && matrix.target == 'x86_64-unknown-linux-gnu'+ if: runner.os == 'Linux' && !matrix.use-crossrun: |sudo apt-get updatesudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev- - name: Install system dependencies (Linux cross arm64)- if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'+ - name: Install cross-compilation tools (Linux ARM64)+ if: matrix.use-crossrun: |sudo apt-get update- sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \- libtesseract-dev:arm64 libleptonica-dev:arm64 || true- # Cross compilation may need additional setup- sudo dpkg --add-architecture arm64- sudo apt-get update- sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libclang-dev- rustup target add aarch64-unknown-linux-gnu+ sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu- name: Install system dependencies (macOS)if: runner.os == 'macOS'@@ -92,11 +117,14 @@ jobs:targetkey: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}- - name: Add target- run: rustup target add ${{ matrix.target }}-- name: Build- run: cargo build --release --target ${{ matrix.target }}+ run: |+ if [ "${{ matrix.use-cross }}" = "true" ]; then+ # Cross-compile without tesseract (C cross-deps are hard)+ cargo build --release --target ${{ matrix.target }} --no-default-features+ else+ cargo build --release --target ${{ matrix.target }}+ fi- name: Package binaryrun: |@@ -113,9 +141,8 @@ jobs:github-release:needs: [build-binaries, publish-crates]+ if: ${{ always() && needs.build-binaries.result == 'success' && (needs.publish-crates.result == 'success' || needs.publish-crates.result == 'skipped') }}runs-on: ubuntu-latest- permissions:- contents: writesteps:- uses: actions/checkout@v4@@ -125,17 +152,33 @@ jobs:with:path: artifacts+ - name: Create git tag+ if: ${{ !inputs.dry-run }}+ run: |+ git tag "crates-v${{ inputs.version }}"+ git push origin "crates-v${{ inputs.version }}"+- name: Create GitHub Release+ if: ${{ !inputs.dry-run }}uses: softprops/action-gh-release@v2with:+ tag_name: crates-v${{ inputs.version }}+ name: "Crates & CLI v${{ inputs.version }}"generate_release_notes: truefiles: artifacts/**/*.tar.gz+ - name: Summary (dry run)+ if: ${{ inputs.dry-run }}+ run: |+ echo "## Dry Run Summary" >> $GITHUB_STEP_SUMMARY+ echo "Would release crates-v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY+ echo "Artifacts:" >> $GITHUB_STEP_SUMMARY+ find artifacts -name "*.tar.gz" -exec echo "- {}" \; >> $GITHUB_STEP_SUMMARY+dispatch-homebrew:needs: github-release+ if: ${{ !inputs.dry-run }}runs-on: ubuntu-latest- permissions:- actions: writesteps:- uses: actions/github-script@v7with:diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.ymlnew file mode 100644index 0000000..69444cd--- /dev/null+++ b/.github/workflows/release-docker.yml@@ -0,0 +1,143 @@+name: Release - Docker++on:+ workflow_dispatch:+ inputs:+ version:+ description: 'Version to release (e.g. 2.1.0)'+ required: true+ type: string+ dry-run:+ description: 'Dry run (build but do not push)'+ type: boolean+ default: false++env:+ REGISTRY: ghcr.io+ IMAGE_NAME_BASE: run-llama/liteparse-base+ IMAGE_NAME: run-llama/liteparse++jobs:+ build-and-publish-base:+ runs-on: ubuntu-latest+ permissions:+ contents: write+ packages: write+ id-token: write++ steps:+ - uses: actions/checkout@v4++ - name: Install cosign+ uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0+ with:+ cosign-release: "v2.2.4"++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226++ - name: Set up QEMU+ uses: docker/setup-qemu-action@v4++ - name: Log into registry+ if: ${{ !inputs.dry-run }}+ uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d+ with:+ registry: ${{ env.REGISTRY }}+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Build and push base image+ id: build-and-push+ uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09+ with:+ platforms: linux/amd64,linux/arm64+ context: .+ push: ${{ !inputs.dry-run }}+ tags: |+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BASE }}:v${{ inputs.version }}+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BASE }}:latest+ cache-from: type=gha+ cache-to: type=gha,mode=max++ - name: Sign the image+ if: ${{ !inputs.dry-run }}+ env:+ DIGEST: ${{ steps.build-and-push.outputs.digest }}+ run: |+ cosign sign --yes "${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BASE }}@${DIGEST}"++ build-and-publish-full:+ runs-on: ubuntu-latest+ permissions:+ contents: write+ packages: write+ id-token: write++ steps:+ - uses: actions/checkout@v4++ - name: Install cosign+ uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0+ with:+ cosign-release: "v2.2.4"++ - name: Set up Docker Buildx+ uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226++ - name: Set up QEMU+ uses: docker/setup-qemu-action@v4++ - name: Log into registry+ if: ${{ !inputs.dry-run }}+ uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d+ with:+ registry: ${{ env.REGISTRY }}+ username: ${{ github.actor }}+ password: ${{ secrets.GITHUB_TOKEN }}++ - name: Build and push full image+ id: build-and-push+ uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09+ with:+ platforms: linux/amd64,linux/arm64+ context: .+ file: full.Dockerfile+ push: ${{ !inputs.dry-run }}+ tags: |+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ inputs.version }}+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest+ cache-from: type=gha+ cache-to: type=gha,mode=max++ - name: Sign the image+ if: ${{ !inputs.dry-run }}+ env:+ DIGEST: ${{ steps.build-and-push.outputs.digest }}+ run: |+ cosign sign --yes "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${DIGEST}"++ create-release:+ needs: [build-and-publish-base, build-and-publish-full]+ if: ${{ !inputs.dry-run }}+ runs-on: ubuntu-latest+ permissions:+ contents: write++ steps:+ - uses: actions/checkout@v4++ - name: Create git tag+ run: |+ git tag "docker-v${{ inputs.version }}"+ git push origin "docker-v${{ inputs.version }}"++ - name: Create GitHub Release+ uses: softprops/action-gh-release@v2+ with:+ tag_name: docker-v${{ inputs.version }}+ name: "Docker v${{ inputs.version }}"+ body: |+ Docker images published to GHCR:+ - `${{ env.REGISTRY }}/${{ env.IMAGE_NAME_BASE }}:v${{ inputs.version }}`+ - `${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:v${{ inputs.version }}`diff --git a/.github/workflows/node-bindings.yml b/.github/workflows/release-node.ymlsimilarity index 58%rename from .github/workflows/node-bindings.ymlrename to .github/workflows/release-node.ymlindex 3664582..c7aaaae 100644--- a/.github/workflows/node-bindings.yml+++ b/.github/workflows/release-node.yml@@ -1,19 +1,41 @@-name: Node.js Bindings+name: Release - Node.json:- push:- branches: [main]- tags: ['v*']- pull_request:- branches: [main]+ workflow_dispatch:+ inputs:+ version:+ description: 'Version to release (e.g. 2.1.0)'+ required: true+ type: string+ dry-run:+ description: 'Dry run (build but do not publish)'+ type: boolean+ default: false++permissions:+ contents: write+ id-token: writeenv:CARGO_TERM_COLOR: always- # pdfium-sys auto-downloads during build, this ensures consistent versionPDFIUM_RELEASE_TAG: chromium/7827jobs:- build:+ validate:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - name: Validate version+ run: |+ PKG_VERSION=$(node -p "require('./packages/node/package.json').version")+ if [ "$PKG_VERSION" != "${{ inputs.version }}" ]; then+ echo "::error::Version mismatch: package.json has $PKG_VERSION, expected ${{ inputs.version }}"+ exit 1+ fi+ echo "Version validated: ${{ inputs.version }}"++ build-bindings:+ needs: validatestrategy:fail-fast: falsematrix:@@ -64,6 +86,17 @@ jobs:sudo apt-get updatesudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu+ - uses: actions/cache@v4+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ ~/.cache/pdfium-rs+ ~/Library/Caches/pdfium-rs+ ${{ runner.os == 'Windows' && format('{0}\pdfium-rs', env.LOCALAPPDATA) || '' }}+ target+ key: ${{ runner.os }}-${{ matrix.target }}-cargo-node-${{ hashFiles('**/Cargo.lock') }}+- name: Install dependenciesworking-directory: packages/noderun: npm ci@@ -82,7 +115,6 @@ jobs:working-directory: packages/nodeshell: pwshrun: |- # Find pdfium.dll in the build cache$cacheBase = "$env:LOCALAPPDATA\pdfium-rs"if (-not (Test-Path $cacheBase)) {$cacheBase = "$env:USERPROFILE\.cache\pdfium-rs"@@ -92,12 +124,8 @@ jobs:Copy-Item $dll.FullName -Destination ".\pdfium.dll"Write-Host "Copied $($dll.FullName) -> .\pdfium.dll"} else {- # Also check for pdfium.dll.lib -> the actual DLL is in bin/- $dllLib = Get-ChildItem -Path $cacheBase -Recurse -Filter "pdfium.dll" -ErrorAction SilentlyContinue | Select-Object -First 1- if (-not $dllLib) {- Write-Error "Could not find pdfium.dll in cache"- exit 1- }+ Write-Error "Could not find pdfium.dll in cache"+ exit 1}- name: Build TypeScript@@ -113,9 +141,8 @@ jobs:packages/node/${{ matrix.pdfium-dylib }}if-no-files-found: error- # Test the built binaries on their native platforms- test:- needs: build+ test-bindings:+ needs: build-bindingsstrategy:fail-fast: falsematrix:@@ -163,15 +190,84 @@ jobs:});"- # Publish to npm on version tags+ build-cli:+ needs: validate+ strategy:+ matrix:+ include:+ - target: x86_64-unknown-linux-gnu+ os: ubuntu-latest+ artifact: lit-linux-x64+ - target: aarch64-unknown-linux-gnu+ os: ubuntu-latest+ artifact: lit-linux-arm64+ use-cross: true+ - target: x86_64-apple-darwin+ os: macos-13+ artifact: lit-darwin-x64+ - target: aarch64-apple-darwin+ os: macos-latest+ artifact: lit-darwin-arm64+ runs-on: ${{ matrix.os }}++ steps:+ - uses: actions/checkout@v4++ - uses: dtolnay/rust-toolchain@stable+ with:+ targets: ${{ matrix.target }}++ - name: Install system dependencies (Linux native)+ if: runner.os == 'Linux' && !matrix.use-cross+ run: |+ sudo apt-get update+ sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev++ - name: Install cross-compilation tools (Linux ARM64)+ if: matrix.use-cross+ run: |+ sudo apt-get update+ sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu++ - name: Install system dependencies (macOS)+ if: runner.os == 'macOS'+ run: brew install tesseract leptonica++ - uses: actions/cache@v4+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ ~/.cache/pdfium-rs+ ~/Library/Caches/pdfium-rs+ target+ key: ${{ runner.os }}-${{ matrix.target }}-cargo-cli-${{ hashFiles('**/Cargo.lock') }}++ - name: Build+ run: |+ if [ "${{ matrix.use-cross }}" = "true" ]; then+ cargo build --release --target ${{ matrix.target }} --no-default-features+ else+ cargo build --release --target ${{ matrix.target }}+ fi++ - name: Package binary+ run: |+ mkdir -p dist+ cp target/${{ matrix.target }}/release/lit dist/${{ matrix.artifact }}+ chmod +x dist/${{ matrix.artifact }}+ tar -czf dist/${{ matrix.artifact }}.tar.gz -C dist ${{ matrix.artifact }}++ - name: Upload artifact+ uses: actions/upload-artifact@v4+ with:+ name: ${{ matrix.artifact }}+ path: dist/${{ matrix.artifact }}.tar.gz+publish:- if: startsWith(github.ref, 'refs/tags/v')- needs: test+ needs: [test-bindings, build-cli]runs-on: ubuntu-latest- name: Publish to npm- permissions:- contents: read- id-token: write+ name: Publish & Releasesteps:- uses: actions/checkout@v4@@ -189,15 +285,21 @@ jobs:working-directory: packages/noderun: npx tsc- - name: Download all artifacts+ - name: Download all binding artifactsuses: actions/download-artifact@v4with:+ pattern: bindings-*path: artifacts+ - name: Download all CLI artifacts+ uses: actions/download-artifact@v4+ with:+ pattern: lit-*+ path: cli-artifacts+- name: Prepare platform packagesworking-directory: packages/noderun: |- # Create and publish platform-specific packagesdeclare -A PLATFORMS=(["darwin-arm64"]="aarch64-apple-darwin"["darwin-x64"]="x86_64-apple-darwin"@@ -218,13 +320,11 @@ jobs:mkdir -p "$PKG_DIR"- # Copy native filescp "$ARTIFACT_DIR"/*.node "$PKG_DIR/" 2>/dev/null || truecp "$ARTIFACT_DIR"/*.dylib "$PKG_DIR/" 2>/dev/null || truecp "$ARTIFACT_DIR"/*.so "$PKG_DIR/" 2>/dev/null || truecp "$ARTIFACT_DIR"/*.dll "$PKG_DIR/" 2>/dev/null || true- # Determine OS and CPU for package.jsoncase "$ARCH" indarwin-arm64) OS="darwin"; CPU="arm64" ;;darwin-x64) OS="darwin"; CPU="x64" ;;@@ -233,7 +333,7 @@ jobs:win32-x64-msvc) OS="win32"; CPU="x64" ;;esac- VERSION=$(node -p "require('./package.json').version")+ VERSION=${{ inputs.version }}cat > "$PKG_DIR/package.json" << PKGJSON{@@ -256,6 +356,7 @@ jobs:done- name: Publish platform packages+ if: ${{ !inputs.dry-run }}working-directory: packages/nodeenv:NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}@@ -270,7 +371,37 @@ jobs:done- name: Publish main package+ if: ${{ !inputs.dry-run }}working-directory: packages/nodeenv:NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}run: npm publish --access public --provenance++ - name: Create git tag+ if: ${{ !inputs.dry-run }}+ run: |+ git tag "node-v${{ inputs.version }}"+ git push origin "node-v${{ inputs.version }}"++ - name: Create GitHub Release+ if: ${{ !inputs.dry-run }}+ uses: softprops/action-gh-release@v2+ with:+ tag_name: node-v${{ inputs.version }}+ name: "Node.js v${{ inputs.version }}"+ generate_release_notes: true+ files: cli-artifacts/**/*.tar.gz++ - name: Summary (dry run)+ if: ${{ inputs.dry-run }}+ run: |+ echo "## Dry Run Summary" >> $GITHUB_STEP_SUMMARY+ echo "Would release node-v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY+ echo "### Platform packages:" >> $GITHUB_STEP_SUMMARY+ for dir in packages/node/npm/*/; do+ if [ -f "$dir/package.json" ]; then+ echo "- $(node -p "require('./${dir}/package.json').name")" >> $GITHUB_STEP_SUMMARY+ fi+ done+ echo "### CLI artifacts:" >> $GITHUB_STEP_SUMMARY+ find cli-artifacts -name "*.tar.gz" -exec echo "- {}" \; >> $GITHUB_STEP_SUMMARYdiff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.ymlnew file mode 100644index 0000000..824b0f8--- /dev/null+++ b/.github/workflows/release-python.yml@@ -0,0 +1,407 @@+name: Release - Python++on:+ workflow_dispatch:+ inputs:+ version:+ description: 'Version to release (e.g. 2.1.0)'+ required: true+ type: string+ dry-run:+ description: 'Dry run (build but do not publish)'+ type: boolean+ default: false++permissions:+ contents: write+ id-token: write++env:+ CARGO_TERM_COLOR: always+ PDFIUM_RELEASE_TAG: chromium/7827++jobs:+ validate:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - name: Validate version+ run: |+ PYPROJECT_VERSION=$(python3 -c "+ import re+ with open('packages/python/pyproject.toml') as f:+ match = re.search(r'^version\s*=\s*\"(.+?)\"', f.read(), re.MULTILINE)+ print(match.group(1))+ ")+ if [ "$PYPROJECT_VERSION" != "${{ inputs.version }}" ]; then+ echo "::error::Version mismatch: pyproject.toml has $PYPROJECT_VERSION, expected ${{ inputs.version }}"+ exit 1+ fi+ echo "Version validated: ${{ inputs.version }}"++ build-wheels:+ needs: validate+ strategy:+ fail-fast: false+ matrix:+ include:+ - os: macos-latest+ target: aarch64-apple-darwin++ - os: macos-13+ target: x86_64-apple-darwin++ - os: ubuntu-latest+ target: x86_64-unknown-linux-gnu++ - os: ubuntu-latest+ target: aarch64-unknown-linux-gnu++ - os: windows-latest+ target: x86_64-pc-windows-msvc++ runs-on: ${{ matrix.os }}+ name: Build ${{ matrix.target }}++ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-python@v5+ with:+ python-version: '3.12'++ - uses: dtolnay/rust-toolchain@stable+ with:+ targets: ${{ matrix.target }}++ - name: Install system dependencies (macOS)+ if: runner.os == 'macOS'+ run: brew install tesseract leptonica++ - uses: actions/cache@v4+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ ~/.cache/pdfium-rs+ ~/Library/Caches/pdfium-rs+ ${{ runner.os == 'Windows' && format('{0}\pdfium-rs', env.LOCALAPPDATA) || '' }}+ target+ key: ${{ runner.os }}-${{ matrix.target }}-cargo-python-${{ hashFiles('**/Cargo.lock') }}++ - name: Build wheels+ uses: PyO3/maturin-action@v1+ with:+ target: ${{ matrix.target }}+ args: --release --out dist+ manylinux: auto+ working-directory: packages/python+ before-script-linux: |+ if command -v yum &> /dev/null; then+ yum install -y clang-devel tesseract-devel leptonica-devel || true+ elif command -v apt-get &> /dev/null; then+ apt-get update && apt-get install -y libclang-dev libtesseract-dev libleptonica-dev || true+ elif command -v apk &> /dev/null; then+ apk add clang-dev tesseract-ocr-dev leptonica-dev || true+ fi++ - name: Copy pdfium dylib into wheel (Unix)+ if: runner.os != 'Windows'+ working-directory: packages/python+ run: |+ bash scripts/copy-pdfium.sh+ for whl in dist/*.whl; do+ python -c "+ import zipfile, os, sys+ whl = sys.argv[1]+ if sys.platform == 'darwin':+ dylib = 'libpdfium.dylib'+ else:+ dylib = 'libpdfium.so'+ dylib_path = os.path.join('liteparse', dylib)+ if not os.path.exists(dylib_path):+ print(f'Warning: {dylib_path} not found, skipping')+ sys.exit(0)+ with zipfile.ZipFile(whl, 'a') as z:+ z.write(dylib_path, f'liteparse/{dylib}')+ print(f'Added {dylib} to {whl}')+ " "$whl"+ done++ - name: Copy pdfium dylib into wheel (Windows)+ if: runner.os == 'Windows'+ working-directory: packages/python+ shell: pwsh+ run: |+ $cacheBase = "$env:LOCALAPPDATA\pdfium-rs"+ if (-not (Test-Path $cacheBase)) {+ $cacheBase = "$env:USERPROFILE\.cache\pdfium-rs"+ }+ $dll = Get-ChildItem -Path $cacheBase -Recurse -Filter "pdfium.dll" | Select-Object -First 1+ if (-not $dll) {+ $dll = Get-ChildItem -Path "..\..\target" -Recurse -Filter "pdfium.dll" | Select-Object -First 1+ }+ if ($dll) {+ Copy-Item $dll.FullName -Destination "liteparse\pdfium.dll"+ Write-Host "Copied $($dll.FullName) -> liteparse\pdfium.dll"+ foreach ($whl in Get-ChildItem dist\*.whl) {+ python -c @"+ import zipfile, sys, os+ whl = sys.argv[1]+ dll = os.path.join('liteparse', 'pdfium.dll')+ if os.path.exists(dll):+ with zipfile.ZipFile(whl, 'a') as z:+ z.write(dll, 'liteparse/pdfium.dll')+ print(f'Added pdfium.dll to {whl}')+ "@ $whl.FullName+ }+ } else {+ Write-Error "Could not find pdfium.dll"+ exit 1+ }++ - name: Upload wheels+ uses: actions/upload-artifact@v4+ with:+ name: wheels-${{ matrix.target }}+ path: packages/python/dist/*.whl+ if-no-files-found: error++ build-sdist:+ needs: validate+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - name: Build sdist+ uses: PyO3/maturin-action@v1+ with:+ command: sdist+ args: --out dist+ working-directory: packages/python++ - name: Upload sdist+ uses: actions/upload-artifact@v4+ with:+ name: sdist+ path: packages/python/dist/*.tar.gz+ if-no-files-found: error++ test-wheels:+ needs: build-wheels+ strategy:+ fail-fast: false+ matrix:+ include:+ - os: macos-latest+ target: aarch64-apple-darwin+ - os: macos-13+ target: x86_64-apple-darwin+ - os: ubuntu-latest+ target: x86_64-unknown-linux-gnu+ - os: windows-latest+ target: x86_64-pc-windows-msvc+ runs-on: ${{ matrix.os }}+ name: Test ${{ matrix.target }}++ steps:+ - uses: actions/checkout@v4++ - uses: actions/setup-python@v5+ with:+ python-version: '3.12'++ - name: Download wheels+ uses: actions/download-artifact@v4+ with:+ name: wheels-${{ matrix.target }}+ path: dist++ - name: Install wheel+ run: pip install --find-links dist liteparse++ - name: Smoke test+ run: |+ python -c "+ from liteparse import LiteParse, ParseResult, ParsedPage, TextItem, ScreenshotResult+ parser = LiteParse(ocr_enabled=False, quiet=True)+ print('LiteParse loaded successfully')+ print(repr(parser))+ "++ - name: Parse test+ run: |+ python -c "+ from liteparse import LiteParse+ parser = LiteParse(ocr_enabled=False, quiet=True, max_pages=2)+ result = parser.parse('demo/docs/apple-10q-q3-2025.pdf')+ assert result.num_pages == 2, f'Expected 2 pages, got {result.num_pages}'+ assert len(result.text) > 0, 'Expected non-empty text'+ page = result.get_page(1)+ assert page is not None, 'Expected page 1'+ assert len(page.text_items) > 0, 'Expected text items'+ print(f'Parsed {result.num_pages} pages, {len(result.text)} chars')+ "++ - name: Bytes parse test+ run: |+ python -c "+ from liteparse import LiteParse+ parser = LiteParse(ocr_enabled=False, quiet=True, max_pages=1)+ with open('demo/docs/apple-10q-q3-2025.pdf', 'rb') as f:+ data = f.read()+ result = parser.parse(data)+ assert result.num_pages == 1+ assert len(result.text) > 0+ print('Bytes parse test passed')+ "++ - name: Screenshot test+ run: |+ python -c "+ from liteparse import LiteParse+ parser = LiteParse(ocr_enabled=False, quiet=True)+ screenshots = parser.screenshot('demo/docs/apple-10q-q3-2025.pdf', page_numbers=[1])+ assert len(screenshots) == 1+ assert screenshots[0].page_num == 1+ assert len(screenshots[0].image_bytes) > 0+ print(f'Screenshot: {screenshots[0].width}x{screenshots[0].height}, {len(screenshots[0].image_bytes)} bytes')+ "++ - name: CLI test+ run: |+ lit --version+ lit parse demo/docs/apple-10q-q3-2025.pdf --no-ocr --max-pages 1 -q | head -5+ echo "CLI test passed"++ build-cli:+ needs: validate+ strategy:+ matrix:+ include:+ - target: x86_64-unknown-linux-gnu+ os: ubuntu-latest+ artifact: lit-linux-x64+ - target: aarch64-unknown-linux-gnu+ os: ubuntu-latest+ artifact: lit-linux-arm64+ use-cross: true+ - target: x86_64-apple-darwin+ os: macos-13+ artifact: lit-darwin-x64+ - target: aarch64-apple-darwin+ os: macos-latest+ artifact: lit-darwin-arm64+ runs-on: ${{ matrix.os }}++ steps:+ - uses: actions/checkout@v4++ - uses: dtolnay/rust-toolchain@stable+ with:+ targets: ${{ matrix.target }}++ - name: Install system dependencies (Linux native)+ if: runner.os == 'Linux' && !matrix.use-cross+ run: |+ sudo apt-get update+ sudo apt-get install -y libclang-dev libtesseract-dev libleptonica-dev++ - name: Install cross-compilation tools (Linux ARM64)+ if: matrix.use-cross+ run: |+ sudo apt-get update+ sudo apt-get install -y libclang-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu++ - name: Install system dependencies (macOS)+ if: runner.os == 'macOS'+ run: brew install tesseract leptonica++ - uses: actions/cache@v4+ with:+ path: |+ ~/.cargo/registry+ ~/.cargo/git+ ~/.cache/pdfium-rs+ ~/Library/Caches/pdfium-rs+ target+ key: ${{ runner.os }}-${{ matrix.target }}-cargo-cli-${{ hashFiles('**/Cargo.lock') }}++ - name: Build+ run: |+ if [ "${{ matrix.use-cross }}" = "true" ]; then+ cargo build --release --target ${{ matrix.target }} --no-default-features+ else+ cargo build --release --target ${{ matrix.target }}+ fi++ - name: Package binary+ run: |+ mkdir -p dist+ cp target/${{ matrix.target }}/release/lit dist/${{ matrix.artifact }}+ chmod +x dist/${{ matrix.artifact }}+ tar -czf dist/${{ matrix.artifact }}.tar.gz -C dist ${{ matrix.artifact }}++ - name: Upload artifact+ uses: actions/upload-artifact@v4+ with:+ name: ${{ matrix.artifact }}+ path: dist/${{ matrix.artifact }}.tar.gz++ publish:+ needs: [test-wheels, build-sdist, build-cli]+ runs-on: ubuntu-latest+ name: Publish & Release++ steps:+ - uses: actions/checkout@v4++ - name: Download all wheels+ uses: actions/download-artifact@v4+ with:+ pattern: wheels-*+ path: dist+ merge-multiple: true++ - name: Download sdist+ uses: actions/download-artifact@v4+ with:+ name: sdist+ path: dist++ - name: Download CLI artifacts+ uses: actions/download-artifact@v4+ with:+ pattern: lit-*+ path: cli-artifacts++ - name: Publish to PyPI+ if: ${{ !inputs.dry-run }}+ uses: pypa/gh-action-pypi-publish@release/v1+ with:+ packages-dir: dist/++ - name: Create git tag+ if: ${{ !inputs.dry-run }}+ run: |+ git tag "python-v${{ inputs.version }}"+ git push origin "python-v${{ inputs.version }}"++ - name: Create GitHub Release+ if: ${{ !inputs.dry-run }}+ uses: softprops/action-gh-release@v2+ with:+ tag_name: python-v${{ inputs.version }}+ name: "Python v${{ inputs.version }}"+ generate_release_notes: true+ files: cli-artifacts/**/*.tar.gz++ - name: Summary (dry run)+ if: ${{ inputs.dry-run }}+ run: |+ echo "## Dry Run Summary" >> $GITHUB_STEP_SUMMARY+ echo "Would release python-v${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY+ echo "### Wheels:" >> $GITHUB_STEP_SUMMARY+ find dist -name "*.whl" -exec echo "- {}" \; >> $GITHUB_STEP_SUMMARY+ echo "### CLI artifacts:" >> $GITHUB_STEP_SUMMARY+ find cli-artifacts -name "*.tar.gz" -exec echo "- {}" \; >> $GITHUB_STEP_SUMMARYdiff --git a/packages/node/package.json b/packages/node/package.jsonindex d49dce8..44c57b7 100644--- a/packages/node/package.json+++ b/packages/node/package.json@@ -22,8 +22,7 @@"defaults": true,"additional": ["aarch64-apple-darwin",- "aarch64-unknown-linux-gnu",- "aarch64-unknown-linux-musl"+ "aarch64-unknown-linux-gnu"]}},@@ -55,9 +54,7 @@"@llamaindex/liteparse-darwin-arm64": "2.0.0","@llamaindex/liteparse-darwin-x64": "2.0.0","@llamaindex/liteparse-linux-arm64-gnu": "2.0.0",- "@llamaindex/liteparse-linux-arm64-musl": "2.0.0","@llamaindex/liteparse-linux-x64-gnu": "2.0.0",- "@llamaindex/liteparse-linux-x64-musl": "2.0.0","@llamaindex/liteparse-win32-x64-msvc": "2.0.0"},"engines": {