Fix windows CI workflow #531
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 | |
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 by gh | |
if: steps.cache_opencv.outputs.cache-hit != 'true' | |
shell: powershell | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh release download --repo shimat/opencv_files 4.10.0.20240612 --pattern "opencv4100_win_x64.zip" --output opencv.zip | |
Expand-Archive -Path opencv.zip -DestinationPath opencv_files -Force -ErrorAction Stop | |
ls opencv_files | |
#- name: Download OpenCV binaries | |
# if: steps.cache_opencv.outputs.cache-hit != 'true' | |
# shell: powershell | |
# run: | | |
# . ".\download_opencv_windows.ps1" | |
- name: Cache Tesseract binaries | |
id: cache_tesseract | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/tesseract_files | |
key: tesseract-41-rev1 | |
- name: Download Tesseract binaries by gh | |
if: steps.cache_tesseract.outputs.cache-hit != 'true' | |
shell: powershell | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh release download --repo shimat/tesseract_vcpkg 2023.07.06 --pattern "*.zip" --output tesseract.zip | |
Expand-Archive -Path tesseract.zip -DestinationPath tesseract_files -Force -ErrorAction Stop | |
New-Item tesseract_files/tesseract_vcpkg -ItemType Directory -Force | |
Move-Item tesseract_files\*\* tesseract_files/tesseract_vcpkg | |
ls tesseract_files/tesseract_vcpkg | |
#- name: Download Tesseract binaries | |
# if: steps.cache_tesseract.outputs.cache-hit != 'true' | |
# shell: powershell | |
# run: | | |
# . ".\download_tesseract_windows.ps1" | |
- 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 |