Fix Windows CI #546
Workflow file for this run
This file contains 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 2022 | |
on: | |
pull_request: | |
types: [synchronize, opened] | |
push: | |
branches: | |
- main | |
env: | |
OPENCV_VERSION: "4.10.0" | |
TESSERACT_RELEASE_VERSION: "2024.08.19" | |
jobs: | |
build: | |
runs-on: windows-2022 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
# - name: Cache restored NuGet packages | |
# uses: actions/cache@v2 | |
# with: | |
# path: ${{ github.workspace }}/.nuget/packages | |
# key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-nuget- | |
- name: Cache OpenCV binaries | |
id: cache_opencv | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/opencv_files | |
key: opencv-${{ env.OPENCV_VERSION }}-rev2 | |
- name: Download OpenCV binaries | |
if: steps.cache_opencv.outputs.cache-hit != 'true' | |
shell: powershell | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
$OPENCV_FILES_TAG = "4.10.0.20240612" | |
$OPENCV_VERSION = "4100" | |
gh release download --repo shimat/opencv_files $OPENCV_FILES_TAG --pattern "opencv${OPENCV_VERSION}_win_x64.zip" | |
gh release download --repo shimat/opencv_files $OPENCV_FILES_TAG --pattern "opencv${OPENCV_VERSION}_win_x86.zip" | |
Expand-Archive -Path opencv${OPENCV_VERSION}_win_x64.zip -DestinationPath opencv_files/opencv4100_win_x64 -Force -ErrorAction Stop | |
Expand-Archive -Path opencv${OPENCV_VERSION}_win_x86.zip -DestinationPath opencv_files/opencv4100_win_x86 -Force -ErrorAction Stop | |
ls opencv_files | |
ls opencv_files/opencv${OPENCV_VERSION}_win_x64 | |
- name: Cache Tesseract binaries | |
id: cache_tesseract | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/tesseract_files | |
key: tesseract-41-rev2 | |
- name: Download Tesseract binaries | |
if: steps.cache_tesseract.outputs.cache-hit != 'true' | |
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 | |
- 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 ARM | |
# shell: cmd | |
# run: msbuild OpenCvSharp.sln /t:build /p:configuration=Release /p:platform=ARM -maxcpucount | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: | | |
8.0.x | |
- name: Build | |
shell: cmd | |
run: | | |
dotnet build src/OpenCvSharp.Extensions/OpenCvSharp.Extensions.csproj -f net6.0 -p:configuration=Release -maxcpucount | |
dotnet build src/OpenCvSharp.WpfExtensions/OpenCvSharp.WpfExtensions.csproj -f net6.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}" | |
(Get-ChildItem $env:GITHUB_WORKSPACE -Recurse).Where{ $_.Extension -eq ".nuspec" }.ForEach{ | |
[xml]$xml = Get-Content $_.FullName | |
$xml.package.metadata.version = $version | |
$xml.Save($_.FullName) | |
} | |
$windowsNuspec = "${env:GITHUB_WORKSPACE}\nuget\OpenCvSharp4.Windows.nuspec" | |
$extensionsNuspec = "${env:GITHUB_WORKSPACE}\nuget\OpenCvSharp4.Extensions.nuspec" | |
$wpfExtensionsNuspec = "${env:GITHUB_WORKSPACE}\nuget\OpenCvSharp4.WpfExtensions.nuspec" | |
$nuspecFiles = @($windowsNuspec, $extensionsNuspec, $wpfExtensionsNuspec) | |
foreach ( $nuspecFile in $nuspecFiles ) { | |
[xml]$xml = Get-Content $nuspecFile | |
foreach ($group in $xml.package.metadata.dependencies.ChildNodes){ | |
foreach ($dependency in $group.ChildNodes){ | |
$packageId = $dependency.GetAttribute("id") | |
if ($packageId.StartsWith("OpenCvSharp")){ | |
Write-Host "before: " $packageId "=" $dependency.GetAttribute("version") | |
$dependency.SetAttribute("version", $version) | |
Write-Host "after: " $packageId "=" $dependency.GetAttribute("version") | |
$xml.Save($nuspecFile) | |
} | |
else { | |
Write-Host "Skipped: " $packageId | |
} | |
} | |
} | |
} | |
nuget pack nuget/OpenCvSharp4.nuspec -OutputDirectory artifacts -Symbols -SymbolPackageFormat snupkg | |
nuget pack nuget/OpenCvSharp4.Windows.nuspec -OutputDirectory artifacts | |
nuget pack nuget/OpenCvSharp4.Extensions.nuspec -OutputDirectory artifacts -Symbols -SymbolPackageFormat snupkg | |
nuget pack nuget/OpenCvSharp4.WpfExtensions.nuspec -OutputDirectory artifacts -Symbols -SymbolPackageFormat snupkg | |
nuget pack nuget/OpenCvSharp4.runtime.win.nuspec -OutputDirectory artifacts | |
- 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@v4 | |
with: | |
name: packages_windows | |
path: ${{ github.workspace }}\artifacts |