docuparse 0.0.5

Document extraction and parsing - PDF text, rendering, and OCR
Documentation
name: Release CLI

on:
  push:
    tags: ["cli-v*"]
  workflow_dispatch:

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build ${{ matrix.target }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: aarch64-apple-darwin
            os: macos-15
          # x86_64 gnu built on ubuntu-24.04: glibc 2.39 floor, matching
          # the statically linked ONNX Runtime shipped through oar-ocr
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-24.04
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-24.04-arm
          # windows omitted: ort-sys 2.0.0-rc.13 panics in
          # build/dynamic_link.rs when CARGO_BUILD_TARGET is set
          # (DLL copy target dir miscomputed); revisit on the next ort release
          # - target: x86_64-pc-windows-msvc
          #   os: windows-latest
          # mac intel omitted: macos-15-latest runner pool was congested
          # (30m+ queue with no outage); revisit when capacity normalizes
          # - target: x86_64-apple-darwin
          #   os: macos-15-latest
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v7

      - name: Install mise
        uses: jdx/mise-action@v4
        with:
          install: true
          bootstrap: true
          bootstrap_args: "--yes"
          bootstrap_skip: "task"
          cache: true

      - name: Cache rust build
        uses: Swatinem/rust-cache@v2

      # - uses: jdx/mr-boxington-action@v1
      #   with:
      #     save-on-workflow-dispatch: "true"

      - name: Add Rust target
        run: rustup target add ${{ matrix.target }}

      - name: Cache ort downloads
        uses: actions/cache@v6
        with:
          path: |
            ~/.cache/ort.pyke.io
            ~/Library/Caches/ort.pyke.io
            ~/AppData/Local/ort.pyke.io
          key: ort-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            ort-${{ matrix.target }}-

      - name: Build
        if: runner.os != 'Windows'
        env:
          CARGO_BUILD_TARGET: ${{ matrix.target }}
        run: mise run build-cli

      - name: Build (Windows, bypass mbx shim)
        if: runner.os == 'Windows'
        shell: bash
        env:
          CARGO_BUILD_TARGET: ${{ matrix.target }}
        run: '"$(rustup which cargo)" build --release -p docuparse-cli --features ocr'

      - name: Package (Unix)
        if: runner.os != 'Windows'
        shell: bash
        run: |
          set -euo pipefail
          staging="docuparse-cli-${{ matrix.target }}"
          mkdir -p "dist/$staging"
          cp "target/${{ matrix.target }}/release/docuparse-cli" "dist/$staging/"
          tar -czf "dist/$staging.tar.gz" -C dist "$staging"
          (
            cd dist
            if command -v sha256sum >/dev/null 2>&1; then
              sha256sum "$staging.tar.gz" > "$staging.tar.gz.sha256"
            else
              shasum -a 256 "$staging.tar.gz" > "$staging.tar.gz.sha256"
            fi
          )

      - name: Package (Windows)
        if: runner.os == 'Windows'
        shell: bash
        run: |
          set -euo pipefail
          staging="docuparse-cli-${{ matrix.target }}"
          mkdir -p "dist/$staging"
          cp "target/${{ matrix.target }}/release/docuparse-cli.exe" "dist/$staging/"
          powershell -NoProfile -Command "Compress-Archive -Path 'dist/$staging' -DestinationPath 'dist/$staging.zip'"
          (
            cd dist
            sha256sum "$staging.zip" > "$staging.zip.sha256" 2>/dev/null \
              || powershell -NoProfile -Command "(Get-FileHash '$staging.zip' -Algorithm SHA256).Hash.ToLower() + '  $staging.zip'" > "$staging.zip.sha256"
          )

      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: docuparse-cli-${{ matrix.target }}
          path: |
            dist/*.tar.gz
            dist/*.zip
            dist/*.sha256
          if-no-files-found: error
          compression-level: 0

  release:
    name: Release
    needs: build
    if: startsWith(github.ref, 'refs/tags/cli-v')
    runs-on: ubuntu-latest
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v8
        with:
          path: dist
          merge-multiple: true

      - name: Consolidate checksums
        run: |
          cd dist
          cat *.sha256 > SHA256SUMS
          rm -- *.sha256

      - name: Create release
        env:
          GH_TOKEN: ${{ github.token }}
          GH_REPO: ${{ github.repository }}
        shell: bash
        run: |
          set -euo pipefail

          tag="${GITHUB_REF_NAME}"
          mapfile -t assets < <(find dist -maxdepth 1 -type f \( -name '*.tar.gz' -o -name '*.zip' -o -name 'SHA256SUMS' \) | sort)

          gh release create "$tag" "${assets[@]}" \
            --verify-tag \
            --title "docuparse-cli ${tag#cli-v}" \
            --generate-notes \
            --notes "Binaries are also installable via mise's HTTP backend; see crates/docuparse-cli/README.md. PDFium and OCR models are fetched separately by the repository's mise tasks."