-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
183 lines (154 loc) · 6.71 KB
/
windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
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