build-extended-artifacts #55
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build-extended-artifacts | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - "v*" | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAMESPACE: ${{ github.repository_owner }} | |
| IMAGE_ROOT: deepseek-ocr | |
| jobs: | |
| docker-images: | |
| name: Build ${{ matrix.variant }} Docker image | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - variant: alpine | |
| dockerfile: docker/Dockerfile.alpine | |
| artifact-name: deepseek-ocr-alpine-bin | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata (${{ matrix.variant }}) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_ROOT }}-${{ matrix.variant }} | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build image (${{ matrix.variant }}) | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| load: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=${{ matrix.variant }} | |
| cache-to: type=gha,scope=${{ matrix.variant }},mode=max | |
| - name: Extract binaries from image | |
| run: | | |
| mkdir -p artifacts/${{ matrix.variant }} | |
| cid=$(docker create ${{ steps.build.outputs.imageid }}) | |
| docker cp "$cid":/usr/local/bin/deepseek-ocr-cli artifacts/${{ matrix.variant }}/ | |
| docker cp "$cid":/usr/local/bin/deepseek-ocr-server artifacts/${{ matrix.variant }}/ | |
| docker rm "$cid" | |
| - name: Upload binaries (${{ matrix.variant }}) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact-name }} | |
| path: artifacts/${{ matrix.variant }} | |
| - name: Archive binaries (${{ matrix.variant }}) | |
| run: tar -czf deepseek-ocr-${{ matrix.variant }}-linux.tar.gz -C artifacts/${{ matrix.variant }} . | |
| - name: Publish release asset (${{ matrix.variant }}) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: deepseek-ocr-${{ matrix.variant }}-linux.tar.gz | |
| windows-cuda-binaries: | |
| name: Build Windows CUDA binaries (${{ matrix.cuda }}, sm_${{ matrix.compute_cap }}) | |
| runs-on: windows-latest | |
| timeout-minutes: 120 | |
| env: | |
| CUDA_COMPUTE_CAP: ${{ matrix.compute_cap }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| cuda: ['12.4.1', '13.0.2'] | |
| compute_cap: [70, 75, 80, 86, 89, 120] | |
| include: | |
| - cuda: '12.4.1' | |
| artifact_suffix_base: cuda12-4-1 | |
| - cuda: '13.0.2' | |
| artifact_suffix_base: cuda13-0-2-preview | |
| exclude: | |
| - cuda: '12.4.1' | |
| compute_cap: 120 | |
| - cuda: '13.0.2' | |
| compute_cap: 70 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~\.cargo\registry | |
| ~\.cargo\git | |
| key: windows-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| windows-cargo- | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| if: matrix.cuda == '13.0.2' | |
| with: | |
| python-version: '3.x' | |
| - name: Install CUDA Toolkit ${{ matrix.cuda }} | |
| uses: Jimver/[email protected] | |
| with: | |
| cuda: ${{ matrix.cuda }} | |
| method: local | |
| log-file-suffix: windows-cuda.txt | |
| - name: Switch Candle manifest to git tip | |
| if: matrix.cuda == '13.0.2' | |
| shell: pwsh | |
| run: | | |
| $pythonCode = @" | |
| from pathlib import Path | |
| path = Path('Cargo.toml') | |
| text = path.read_text() | |
| stable_core = 'candle-core = { version = "0.9", default-features = false }' | |
| stable_nn = 'candle-nn = { version = "0.9", default-features = false }' | |
| git_core = 'candle-core = { git = "https://github.com/huggingface/candle", rev = "d4545ebbbfb37d3cf0e228642ffaaa75b5d6bce9", default-features = false }' | |
| git_nn = 'candle-nn = { git = "https://github.com/huggingface/candle", rev = "d4545ebbbfb37d3cf0e228642ffaaa75b5d6bce9", default-features = false }' | |
| if stable_core not in text or stable_nn not in text: | |
| raise SystemExit('Expected stable candle deps not found in Cargo.toml') | |
| text = text.replace(stable_core, git_core, 1) | |
| text = text.replace(stable_nn, git_nn, 1) | |
| path.write_text(text) | |
| "@ | |
| python -c $pythonCode | |
| - name: Upgrade Candle to git tip for CUDA 13 | |
| if: matrix.cuda == '13.0.2' | |
| shell: pwsh | |
| run: | | |
| cargo fetch | |
| - name: Locate MSVC toolchain | |
| shell: pwsh | |
| run: | | |
| $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' | |
| if (-not (Test-Path $vswhere)) { throw "vswhere.exe not found" } | |
| $installPath = & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | |
| if (-not $installPath) { throw "MSVC build tools not found" } | |
| $clRoot = Join-Path $installPath 'VC\Tools\MSVC' | |
| if (-not (Test-Path $clRoot)) { throw "Unable to locate VC tools under $installPath" } | |
| $vcVersion = Get-ChildItem $clRoot -Directory | Sort-Object Name -Descending | Select-Object -First 1 | |
| if (-not $vcVersion) { throw "No VC toolset directories found in $clRoot" } | |
| $binDir = Join-Path $vcVersion.FullName 'bin\Hostx64\x64' | |
| $clExe = Join-Path $binDir 'cl.exe' | |
| if (-not (Test-Path $clExe)) { throw "cl.exe not found at $clExe" } | |
| Add-Content $env:GITHUB_PATH $binDir | |
| Add-Content $env:GITHUB_ENV "VCToolsInstallDir=$($vcVersion.FullName)" | |
| Add-Content $env:GITHUB_ENV "NVCC_CCBIN=$clExe" | |
| - name: Build CLI with CUDA | |
| shell: pwsh | |
| run: cargo build --locked --release --no-default-features --features cuda -p deepseek-ocr-cli | |
| - name: Build server with CUDA | |
| shell: pwsh | |
| run: cargo build --locked --release --no-default-features --features cuda -p deepseek-ocr-server | |
| - name: Collect CUDA binaries | |
| shell: pwsh | |
| run: | | |
| $artifactPath = "artifacts\\windows-${{ matrix.artifact_suffix_base }}-sm${{ matrix.compute_cap }}" | |
| New-Item -ItemType Directory -Force -Path $artifactPath | Out-Null | |
| Copy-Item target\release\deepseek-ocr-cli.exe $artifactPath | |
| Copy-Item target\release\deepseek-ocr-server.exe $artifactPath | |
| - name: Upload CUDA Windows binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: deepseek-ocr-windows-${{ matrix.artifact_suffix_base }}-sm${{ matrix.compute_cap }} | |
| path: artifacts\windows-${{ matrix.artifact_suffix_base }}-sm${{ matrix.compute_cap }} | |
| - name: Package CUDA Windows binaries | |
| shell: pwsh | |
| run: | | |
| $artifactPath = "artifacts\\windows-${{ matrix.artifact_suffix_base }}-sm${{ matrix.compute_cap }}" | |
| $zipName = "deepseek-ocr-windows-${{ matrix.artifact_suffix_base }}-sm${{ matrix.compute_cap }}.zip" | |
| Compress-Archive -Path "$artifactPath\*" -DestinationPath $zipName -Force | |
| - name: Publish release asset (Windows CUDA) | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: deepseek-ocr-windows-${{ matrix.artifact_suffix_base }}-sm${{ matrix.compute_cap }}.zip | |
| - name: Restore manifest and lockfile | |
| if: matrix.cuda == '13.0.2' | |
| shell: pwsh | |
| run: git checkout -- Cargo.toml Cargo.lock |