Skip to content

fix: add MSVC toolchain location step in Windows CUDA build workflow #11

fix: add MSVC toolchain location step in Windows CUDA build workflow

fix: add MSVC toolchain location step in Windows CUDA build workflow #11

name: build-extended-artifacts
on:
push:
branches:
- feature/docker
tags:
- "v*"
pull_request:
branches:
- master
permissions:
contents: write
packages: write
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
- variant: cuda
dockerfile: docker/Dockerfile.cuda
artifact-name: deepseek-ocr-cuda-bin
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image (${{ matrix.variant }})
id: build
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: false
load: true
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 ${{ 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: ${{ matrix.variant }}-linux.tar.gz
windows-cuda-binaries:
name: Build Windows CUDA binaries
runs-on: windows-latest
timeout-minutes: 120
env:
CUDA_COMPUTE_CAP: "80"
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: Install CUDA Toolkit 12.2
uses: Jimver/cuda-toolkit@v0.2.24
with:
cuda: '12.2.2'
method: local
log-file-suffix: windows-cuda.txt
- 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: |
New-Item -ItemType Directory -Force -Path artifacts\windows-cuda | Out-Null
Copy-Item target\release\deepseek-ocr-cli.exe artifacts\windows-cuda\
Copy-Item target\release\deepseek-ocr-server.exe artifacts\windows-cuda\
- name: Upload CUDA Windows binaries
uses: actions/upload-artifact@v4
with:
name: deepseek-ocr-windows-cuda
path: artifacts\windows-cuda
- name: Package CUDA Windows binaries
shell: pwsh
run: |
Compress-Archive -Path artifacts\windows-cuda\* -DestinationPath windows-cuda.zip -Force
- name: Publish release asset (Windows CUDA)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: windows-cuda.zip