Merge pull request #1828 from shimat/FaceDetectorYN_test #744
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: Windows Server 2025 | |
| on: | |
| pull_request: | |
| types: [synchronize, opened] | |
| push: | |
| branches: | |
| - main | |
| env: | |
| OPENCV_VERSION: "4.13.0" | |
| OPENCV_FILES_TAG: "4.13.0.20260207" | |
| TESSERACT_RELEASE_VERSION: "2024.08.19" | |
| jobs: | |
| build: | |
| runs-on: windows-2025 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 1 | |
| submodules: true | |
| # - name: Cache restored NuGet packages | |
| # uses: actions/cache@v5 | |
| # with: | |
| # path: ${{ github.workspace }}/.nuget/packages | |
| # key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-nuget- | |
| - name: Download OpenCV binaries | |
| shell: powershell | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh release download --repo shimat/opencv_files ${env:OPENCV_FILES_TAG} --pattern "opencv_win_x64.zip" | |
| gh release download --repo shimat/opencv_files ${env:OPENCV_FILES_TAG} --pattern "opencv_win_x86.zip" | |
| Expand-Archive -Path opencv_win_x64.zip -DestinationPath opencv_files/opencv_win_x64 -Force -ErrorAction Stop | |
| Expand-Archive -Path opencv_win_x86.zip -DestinationPath opencv_files/opencv_win_x86 -Force -ErrorAction Stop | |
| ls opencv_files | |
| ls opencv_files/opencv_win_x64 | |
| - name: Download Tesseract binaries | |
| shell: powershell | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| gh release download --repo shimat/tesseract_vcpkg ${TESSERACT_RELEASE_VERSION} --pattern "*.zip" --output tesseract.zip | |
| Expand-Archive -Path tesseract.zip -DestinationPath tesseract_files -Force -ErrorAction Stop | |
| ls tesseract_files | |
| Move-Item tesseract_files/tesseract_vcpkg.0.0.9-beta tesseract_files/tesseract_vcpkg | |
| ls tesseract_files/tesseract_vcpkg | |
| New-Item tesseract_files/tesseract_vcpkg -ItemType Directory -Force | |
| Move-Item tesseract_files/tesseract_vcpkg/installed/* tesseract_files/tesseract_vcpkg/ | |
| ls tesseract_files/tesseract_vcpkg | |
| - name: NuGet restore | |
| shell: cmd | |
| run: | | |
| nuget restore | |
| # Commented out: FFmpeg backend is included in opencv_videoio_ffmpeg DLLs | |
| # If video tests fail, uncomment this step | |
| #- name: Install Server-Media-Foundation | |
| # shell: powershell | |
| # run: | | |
| # Install-WindowsFeature Server-Media-Foundation | |
| - name: Add msbuild to PATH | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Build x64 | |
| shell: cmd | |
| run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=x64 -maxcpucount | |
| - name: Build x86 | |
| shell: cmd | |
| run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=x86 -maxcpucount | |
| - name: Build slim native runtime (x64/x86) | |
| shell: powershell | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| # Compile OpenCvSharpExtern in "slim" mode by disabling selected wrapper modules. | |
| # These NO_* macros are consumed by OpenCvSharpExtern headers. | |
| $slimDefines = "/DNO_CONTRIB /DNO_STITCHING /DNO_VIDEO /DNO_VIDEOIO /DNO_HIGHGUI /DNO_DNN /DNO_ML /DNO_BARCODE" | |
| $env:CL = "$slimDefines $env:CL" | |
| # Keep slim outputs/intermediates separate from the full Release build artifacts. | |
| # This avoids reusing non-slim object files from earlier steps. | |
| $slimOutX64 = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/x64/" | |
| $slimOutX86 = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/Win32/" | |
| $slimIntX64 = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/obj/x64/" | |
| $slimIntX86 = Join-Path $env:GITHUB_WORKSPACE "src/ReleaseSlim/obj/Win32/" | |
| New-Item -Path $slimOutX64 -ItemType Directory -Force | Out-Null | |
| New-Item -Path $slimOutX86 -ItemType Directory -Force | Out-Null | |
| New-Item -Path $slimIntX64 -ItemType Directory -Force | Out-Null | |
| New-Item -Path $slimIntX86 -ItemType Directory -Force | Out-Null | |
| # Rebuild forces recompilation with the slim defines for deterministic slim binaries. | |
| msbuild src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj ` | |
| /t:Rebuild ` | |
| /p:Configuration=Release ` | |
| /p:Platform=x64 ` | |
| /p:SolutionDir="${env:GITHUB_WORKSPACE}\\" ` | |
| /p:OutDir="$slimOutX64" ` | |
| /p:IntDir="$slimIntX64" ` | |
| /p:PostBuildEventUseInBuild=false ` | |
| /p:RunPostBuildEvent=Never ` | |
| -maxcpucount | |
| msbuild src/OpenCvSharpExtern/OpenCvSharpExtern.vcxproj ` | |
| /t:Rebuild ` | |
| /p:Configuration=Release ` | |
| /p:Platform=Win32 ` | |
| /p:SolutionDir="${env:GITHUB_WORKSPACE}\\" ` | |
| /p:OutDir="$slimOutX86" ` | |
| /p:IntDir="$slimIntX86" ` | |
| /p:PostBuildEventUseInBuild=false ` | |
| /p:RunPostBuildEvent=Never ` | |
| -maxcpucount | |
| $x64Dll = Get-ChildItem "$slimOutX64" -Recurse -Filter OpenCvSharpExtern.dll | Select-Object -First 1 | |
| $x86Dll = Get-ChildItem "$slimOutX86" -Recurse -Filter OpenCvSharpExtern.dll | Select-Object -First 1 | |
| if (-not $x64Dll -or -not $x86Dll) { | |
| throw "Failed to locate slim OpenCvSharpExtern.dll outputs" | |
| } | |
| Copy-Item $x64Dll.FullName "src/Release/x64/OpenCvSharpExtern.Slim.dll" -Force | |
| Copy-Item $x86Dll.FullName "src/Release/Win32/OpenCvSharpExtern.Slim.dll" -Force | |
| #- name: Build ARM | |
| # shell: cmd | |
| # run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=ARM -maxcpucount | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| - name: Build | |
| shell: cmd | |
| run: | | |
| dotnet build src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -f net8.0 -p:configuration=Release -maxcpucount | |
| dotnet build src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -f net8.0-windows -p:configuration=Release -maxcpucount | |
| - name: Pack NuGet packages | |
| shell: powershell | |
| run: | | |
| $ErrorActionPreference = "Stop" | |
| $date = Get-Date -Format "yyyyMMdd" | |
| $version = "${env:OPENCV_VERSION}.${date}-beta" | |
| Write-Host "version = ${version}" | |
| # Pack main libraries | |
| dotnet pack src/OpenCvSharp/OpenCvSharp.csproj -c Release -o artifacts -p:Version=$version | |
| dotnet pack src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -c Release -o artifacts -p:Version=$version | |
| dotnet pack src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -c Release -o artifacts -p:Version=$version | |
| # Pack runtime packages | |
| dotnet pack nuget/OpenCvSharp4.runtime.win.csproj -o artifacts -p:Version=$version | |
| dotnet pack nuget/OpenCvSharp4.runtime.win.slim.csproj -o artifacts -p:Version=$version | |
| # Add local artifacts as NuGet source for meta-package | |
| dotnet nuget add source "${env:GITHUB_WORKSPACE}\artifacts" --name LocalPackages | |
| # Pack meta-package (depends on packages built above) | |
| dotnet pack nuget/OpenCvSharp4.Windows.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version | |
| dotnet pack nuget/OpenCvSharp4.Windows.Slim.csproj -o artifacts -p:Version=$version -p:PackageVersion=$version | |
| - name: Test | |
| shell: powershell | |
| run: | | |
| cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests | |
| dotnet test -c Release -f net48 --runtime win-x64 | |
| - name: Test Windows-only functions | |
| shell: powershell | |
| run: | | |
| cd ${env:GITHUB_WORKSPACE}\test\OpenCvSharp.Tests.Windows | |
| dotnet test -c Release -f net48 --runtime win-x64 | |
| - name: Run ReleaseMaker | |
| shell: powershell | |
| run: | | |
| cd "${env:GITHUB_WORKSPACE}\tool\OpenCvSharp.ReleaseMaker" | |
| dotnet run -c Release --runtime win-x64 -- "${env:GITHUB_WORKSPACE}" "${env:GITHUB_WORKSPACE}\artifacts" ${{env.OPENCV_VERSION}} | |
| - name: Upload NuGet packages and Release packages | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: packages_windows | |
| path: ${{ github.workspace }}\artifacts |