docuparse 0.0.4

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: x86_64-apple-darwin
            os: macos-15-latest
          - 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
          - target: x86_64-pc-windows-msvc
            os: windows-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

      - 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
        env:
          CARGO_BUILD_TARGET: ${{ matrix.target }}
        run: mise run build-cli

      - 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}"
          assets=(dist/*.tar.gz dist/*.zip dist/SHA256SUMS)

          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."