-
Notifications
You must be signed in to change notification settings - Fork 81
233 lines (208 loc) · 10.4 KB
/
build.yml
File metadata and controls
233 lines (208 loc) · 10.4 KB
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# New BSD 3-Clause License (https://github.com/Krypton-Suite/Standard-Toolkit/blob/master/LICENSE)
# Modifications by Peter Wagner (aka Wagnerp), Simon Coghlan (aka Smurf-IV), tobitege et al. 2025 - 2026. All rights reserved.
name: Build
on:
pull_request:
branches: ['**']
types: [opened, synchronize, reopened]
push:
branches:
- master
- alpha
- canary
- gold
- V105-LTS
- V85-LTS
paths-ignore: ['.git*', '.vscode']
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'workflow_dispatch')
steps:
- name: Checkout
uses: actions/checkout@v6
# .NET 9 and 10
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
9.0.x
10.0.x
# .NET 11 (Preview)
- name: Setup .NET 11 (Preview)
uses: actions/setup-dotnet@v5
with:
dotnet-version: 11.0.x
dotnet-quality: preview
# global.json dynamically generate (use latest SDK available)
- name: Force .NET 11 SDK via global.json
run: |
$sdkVersion = (dotnet --list-sdks | Select-String "11.0").ToString().Split(" ")[0]
if (-not $sdkVersion) {
# Fallback to .NET 10 if .NET 11 is not available
$sdkVersion = (dotnet --list-sdks | Select-String "10.0").ToString().Split(" ")[0]
}
Write-Output "Using SDK $sdkVersion"
@"
{
"sdk": {
"version": "$sdkVersion",
"rollForward": "latestFeature"
}
}
"@ | Out-File -Encoding utf8 global.json
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
- name: Cache NuGet
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Populate WebView2 (latest)
shell: pwsh
run: |
$root = $env:GITHUB_WORKSPACE
if (-not $root) { $root = (Get-Location).Path }
$utilProj = Join-Path $root "Source\Krypton Components\Krypton.Utilities\Krypton.Utilities.csproj"
$libDir = Join-Path $root "Source\Krypton Components\Krypton.Utilities\Lib\WebView2"
if (-not (Test-Path $utilProj)) { Write-Error "Project not found: $utilProj"; exit 1 }
if (-not (Test-Path $libDir)) { New-Item -ItemType Directory -Path $libDir -Force }
$packageId = "Microsoft.Web.WebView2"
# Use prerelease versions for alpha and canary branches to avoid .NET 11.0 requirement
$usePrerelease = ($env:GITHUB_REF -eq 'refs/heads/alpha' -or $env:GITHUB_REF -eq 'refs/heads/canary')
$prereleaseParam = if ($usePrerelease) { "true" } else { "false" }
Write-Host "Using prerelease=$prereleaseParam for WebView2 SDK lookup"
$latestVersion = $null
try {
$searchResponse = Invoke-RestMethod -Uri "https://azuresearch-usnc.nuget.org/query?q=$packageId&prerelease=$prereleaseParam&semVerLevel=2.0.0&take=1" -Method Get
if ($searchResponse.data -and $searchResponse.data.Count -gt 0) { $latestVersion = $searchResponse.data[0].version }
} catch {
try {
$response = Invoke-RestMethod -Uri "https://api.nuget.org/v3-flatcontainer/$packageId/index.json" -Method Get
if ($usePrerelease) {
# Include prerelease versions
$allVersions = $response.versions | Where-Object { $_ -match '^\d+\.\d+\.\d+' }
if ($allVersions) { $latestVersion = $allVersions | Sort-Object { [System.Version]($_ -replace '-.*', '') } -Descending | Select-Object -First 1 }
} else {
$stableVersions = $response.versions | Where-Object { $_ -notmatch '[-]' -and $_ -match '^\d+\.\d+\.\d+$' }
if ($stableVersions) { $latestVersion = $stableVersions | Sort-Object { [System.Version]$_ } -Descending | Select-Object -First 1 }
}
} catch {}
}
if (-not $latestVersion) { $latestVersion = "1.0.3595.46" }
Write-Host "Using WebView2 ($(if ($usePrerelease) { 'preview' } else { 'latest' })): $latestVersion"
dotnet add $utilProj package $packageId --version $latestVersion
dotnet restore $utilProj
$nugetBase = Join-Path $env:USERPROFILE ".nuget\packages\microsoft.web.webview2\$latestVersion"
@("Microsoft.Web.WebView2.Core.dll","Microsoft.Web.WebView2.WinForms.dll","WebView2Loader.dll") | ForEach-Object {
$f = Get-ChildItem -Path $nugetBase -Recurse -Name $_ -ErrorAction SilentlyContinue | Select-Object -First 1
if ($f) { Copy-Item (Join-Path $nugetBase $f) $libDir -Force; Write-Host "Copied $_" }
}
dotnet remove $utilProj package $packageId
- name: Restore
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.slnx"
- name: Build
run: msbuild "Scripts/Build/nightly.proj" /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU"
release:
runs-on: windows-latest
if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
needs: build
steps:
- name: Checkout
uses: actions/checkout@v6
# .NET 9 and 10
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
9.0.x
10.0.x
# global.json dynamically generate
- name: Force .NET 10 SDK via global.json
run: |
$sdkVersion = (dotnet --list-sdks | Select-String "10.0").ToString().Split(" ")[0]
Write-Output "Using SDK $sdkVersion"
@"
{
"sdk": {
"version": "$sdkVersion",
"rollForward": "latestFeature"
}
}
"@ | Out-File -Encoding utf8 global.json
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
with:
msbuild-architecture: x64
- name: Setup NuGet
uses: NuGet/setup-nuget@v2.0.1
- name: Cache NuGet
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Populate WebView2 (latest)
shell: pwsh
run: |
$root = $env:GITHUB_WORKSPACE
if (-not $root) { $root = (Get-Location).Path }
$utilProj = Join-Path $root "Source\Krypton Components\Krypton.Utilities\Krypton.Utilities.csproj"
$libDir = Join-Path $root "Source\Krypton Components\Krypton.Utilities\Lib\WebView2"
if (-not (Test-Path $utilProj)) { Write-Error "Project not found: $utilProj"; exit 1 }
if (-not (Test-Path $libDir)) { New-Item -ItemType Directory -Path $libDir -Force }
$packageId = "Microsoft.Web.WebView2"
# Use prerelease versions for alpha and canary branches to avoid .NET 11.0 requirement
$usePrerelease = ($env:GITHUB_REF -eq 'refs/heads/alpha' -or $env:GITHUB_REF -eq 'refs/heads/canary')
$prereleaseParam = if ($usePrerelease) { "true" } else { "false" }
Write-Host "Using prerelease=$prereleaseParam for WebView2 SDK lookup"
$latestVersion = $null
try {
$searchResponse = Invoke-RestMethod -Uri "https://azuresearch-usnc.nuget.org/query?q=$packageId&prerelease=$prereleaseParam&semVerLevel=2.0.0&take=1" -Method Get
if ($searchResponse.data -and $searchResponse.data.Count -gt 0) { $latestVersion = $searchResponse.data[0].version }
} catch {
try {
$response = Invoke-RestMethod -Uri "https://api.nuget.org/v3-flatcontainer/$packageId/index.json" -Method Get
if ($usePrerelease) {
# Include prerelease versions
$allVersions = $response.versions | Where-Object { $_ -match '^\d+\.\d+\.\d+' }
if ($allVersions) { $latestVersion = $allVersions | Sort-Object { [System.Version]($_ -replace '-.*', '') } -Descending | Select-Object -First 1 }
} else {
$stableVersions = $response.versions | Where-Object { $_ -notmatch '[-]' -and $_ -match '^\d+\.\d+\.\d+$' }
if ($stableVersions) { $latestVersion = $stableVersions | Sort-Object { [System.Version]$_ } -Descending | Select-Object -First 1 }
}
} catch {}
}
if (-not $latestVersion) { $latestVersion = "1.0.3595.46" }
Write-Host "Using WebView2 ($(if ($usePrerelease) { 'preview' } else { 'latest' })): $latestVersion"
dotnet add $utilProj package $packageId --version $latestVersion
dotnet restore $utilProj
$nugetBase = Join-Path $env:USERPROFILE ".nuget\packages\microsoft.web.webview2\$latestVersion"
@("Microsoft.Web.WebView2.Core.dll","Microsoft.Web.WebView2.WinForms.dll","WebView2Loader.dll") | ForEach-Object {
$f = Get-ChildItem -Path $nugetBase -Recurse -Name $_ -ErrorAction SilentlyContinue | Select-Object -First 1
if ($f) { Copy-Item (Join-Path $nugetBase $f) $libDir -Force; Write-Host "Copied $_" }
}
dotnet remove $utilProj package $packageId
- name: Restore
run: dotnet restore "Source/Krypton Components/Krypton Toolkit Suite 2022 - VS2022.slnx"
- name: Build Release
run: msbuild "Scripts/Build/build.proj" /t:Build /p:Configuration=Release /p:Platform="Any CPU"
- name: Pack Release
run: msbuild "Scripts/Build/build.proj" /t:Pack /p:Configuration=Release /p:Platform="Any CPU"
- name: Get Version
id: get_version
run: |
$version = (dotnet build "Source/Krypton Components/Krypton.Toolkit/Krypton.Toolkit.csproj" --no-restore --verbosity quiet | Select-String "Version" | ForEach-Object { $_.Line.Split('=')[1].Trim() })
if (-not $version) {
$version = "100.25.1.1" # Fallback version
}
echo "version=$version" >> $env:GITHUB_OUTPUT
echo "tag=v$version" >> $env:GITHUB_OUTPUT