-
Notifications
You must be signed in to change notification settings - Fork 81
196 lines (172 loc) · 8.16 KB
/
build.yml
File metadata and controls
196 lines (172 loc) · 8.16 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
# 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
# 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: |
$libDir = "Source/Krypton Components/Krypton.Utilities/Lib/WebView2"
if (-not (Test-Path $libDir)) { New-Item -ItemType Directory -Path $libDir -Force }
$packageId = "Microsoft.Web.WebView2"
$latestVersion = $null
try {
$searchUrl = "https://azuresearch-usnc.nuget.org/query?q=$packageId&prerelease=false&semVerLevel=2.0.0&take=1"
$searchResponse = Invoke-RestMethod -Uri $searchUrl -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
$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 (latest): $latestVersion"
dotnet add "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package $packageId --version $latestVersion
dotnet restore "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj"
$nugetBase = "$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 "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" 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: |
$libDir = "Source/Krypton Components/Krypton.Utilities/Lib/WebView2"
if (-not (Test-Path $libDir)) { New-Item -ItemType Directory -Path $libDir -Force }
$packageId = "Microsoft.Web.WebView2"
$latestVersion = $null
try {
$searchUrl = "https://azuresearch-usnc.nuget.org/query?q=$packageId&prerelease=false&semVerLevel=2.0.0&take=1"
$searchResponse = Invoke-RestMethod -Uri $searchUrl -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
$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 (latest): $latestVersion"
dotnet add "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" package $packageId --version $latestVersion
dotnet restore "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj"
$nugetBase = "$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 "Source/Krypton Components/Krypton.Utilities/Krypton.Utilities.csproj" 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