-
Notifications
You must be signed in to change notification settings - Fork 59
262 lines (224 loc) · 12.2 KB
/
build.yml
File metadata and controls
262 lines (224 loc) · 12.2 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: Build
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
release:
types: [published]
permissions:
contents: write
id-token: write
actions: read
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v5
- name: Detect changed paths
id: filter
if: github.event_name != 'release'
uses: dorny/paths-filter@v3
with:
# On push events, compare against the previous commit on this branch
# (github.event.before). Without this, the action defaults to comparing
# against the default branch on non-default branch pushes, which would
# match every accumulated change and defeat the filter.
base: ${{ github.event_name == 'push' && github.event.before || '' }}
filters: |
lite_analysis:
- 'Lite/Analysis/**'
- 'Lite/Services/**'
- 'Lite/DuckDb/**'
- 'Lite/Models/**'
- 'Lite.Tests/**'
- 'Lite/PerformanceMonitorLite.csproj'
installer:
- 'Installer/**'
- 'Installer.Core/**'
- 'Installer.Tests/**'
- 'install/**'
- 'upgrades/**'
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
cache: true
cache-dependency-path: '**/packages.lock.json'
- name: Restore dependencies
run: |
dotnet restore Dashboard/Dashboard.csproj --locked-mode
dotnet restore Lite/PerformanceMonitorLite.csproj --locked-mode
dotnet restore Installer/PerformanceMonitorInstaller.csproj --locked-mode
dotnet restore Lite.Tests/Lite.Tests.csproj --locked-mode
dotnet restore Installer.Tests/Installer.Tests.csproj --locked-mode
- name: Build Lite.Tests
run: dotnet build Lite.Tests/Lite.Tests.csproj -c Release --no-restore
- name: Build Installer.Tests
run: dotnet build Installer.Tests/Installer.Tests.csproj -c Release --no-restore
- name: Run Lite fast tests
run: dotnet test Lite.Tests/Lite.Tests.csproj -c Release --no-build --verbosity normal --filter "FullyQualifiedName!~AnomalyDetectorTests&FullyQualifiedName!~FactCollectorTests&FullyQualifiedName!~FactCollectorMiseryTests&FullyQualifiedName!~BaselineProviderTests&FullyQualifiedName!~InferenceEngineTests&FullyQualifiedName!~ScenarioTests&FullyQualifiedName!~AnalysisServiceTests"
- name: Run Lite analysis-heavy tests
if: steps.filter.outputs.lite_analysis == 'true' || github.event_name == 'release'
run: dotnet test Lite.Tests/Lite.Tests.csproj -c Release --no-build --verbosity normal --filter "FullyQualifiedName~AnomalyDetectorTests|FullyQualifiedName~FactCollectorTests|FullyQualifiedName~FactCollectorMiseryTests|FullyQualifiedName~BaselineProviderTests|FullyQualifiedName~InferenceEngineTests|FullyQualifiedName~ScenarioTests|FullyQualifiedName~AnalysisServiceTests"
- name: Run Installer tests
if: steps.filter.outputs.installer == 'true' || github.event_name == 'release'
run: dotnet test Installer.Tests/Installer.Tests.csproj -c Release --no-build --verbosity normal --filter "FullyQualifiedName!~VersionDetectionTests&FullyQualifiedName!~IdempotencyTests&FullyQualifiedName!~AdversarialTests"
- name: Get version
id: version
shell: pwsh
run: |
$version = ([xml](Get-Content Dashboard/Dashboard.csproj)).Project.PropertyGroup.Version | Where-Object { $_ }
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
- name: Publish Dashboard
run: dotnet publish Dashboard/Dashboard.csproj -c Release -o publish/Dashboard
- name: Publish Dashboard (self-contained for Velopack)
if: github.event_name == 'release'
run: dotnet publish Dashboard/Dashboard.csproj -c Release -r win-x64 --self-contained -o publish/Dashboard-velopack
- name: Publish Lite
run: dotnet publish Lite/PerformanceMonitorLite.csproj -c Release -o publish/Lite
- name: Publish Lite (self-contained for Velopack)
if: github.event_name == 'release'
run: dotnet publish Lite/PerformanceMonitorLite.csproj -c Release -r win-x64 --self-contained -o publish/Lite-velopack
- name: Publish CLI Installer
run: dotnet publish Installer/PerformanceMonitorInstaller.csproj -c Release
- name: Package release artifacts
if: github.event_name == 'release'
shell: pwsh
run: |
$version = "${{ steps.version.outputs.VERSION }}"
New-Item -ItemType Directory -Force -Path releases
# Dashboard ZIP
Compress-Archive -Path 'publish/Dashboard/*' -DestinationPath "releases/PerformanceMonitorDashboard-$version.zip" -Force
# Lite ZIP
Compress-Archive -Path 'publish/Lite/*' -DestinationPath "releases/PerformanceMonitorLite-$version.zip" -Force
# Installer ZIP (CLI + SQL scripts)
$instDir = 'publish/Installer'
New-Item -ItemType Directory -Force -Path $instDir
New-Item -ItemType Directory -Force -Path "$instDir/install"
New-Item -ItemType Directory -Force -Path "$instDir/upgrades"
Copy-Item 'Installer/bin/Release/net8.0/win-x64/publish/PerformanceMonitorInstaller.exe' $instDir
Copy-Item 'install/*.sql' "$instDir/install/"
if (Test-Path 'upgrades') { Copy-Item 'upgrades/*' "$instDir/upgrades/" -Recurse -ErrorAction SilentlyContinue }
if (Test-Path 'README.md') { Copy-Item 'README.md' $instDir }
if (Test-Path 'LICENSE') { Copy-Item 'LICENSE' $instDir }
if (Test-Path 'THIRD_PARTY_NOTICES.md') { Copy-Item 'THIRD_PARTY_NOTICES.md' $instDir }
Compress-Archive -Path 'publish/Installer/*' -DestinationPath "releases/PerformanceMonitorInstaller-$version.zip" -Force
- name: Upload Dashboard for signing
if: github.event_name == 'release'
id: upload-dashboard
uses: actions/upload-artifact@v6
with:
name: Dashboard-unsigned
path: publish/Dashboard/
- name: Upload Lite for signing
if: github.event_name == 'release'
id: upload-lite
uses: actions/upload-artifact@v6
with:
name: Lite-unsigned
path: publish/Lite/
- name: Upload Installer for signing
if: github.event_name == 'release'
id: upload-installer
uses: actions/upload-artifact@v6
with:
name: Installer-unsigned
path: publish/Installer/
- name: Sign Dashboard
if: github.event_name == 'release'
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '7969f8b6-d946-4a74-9bac-a55856d8b8e0'
project-slug: 'PerformanceMonitor'
signing-policy-slug: 'release-signing'
artifact-configuration-slug: 'Dashboard'
github-artifact-id: '${{ steps.upload-dashboard.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: 'signed/Dashboard'
- name: Sign Lite
if: github.event_name == 'release'
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '7969f8b6-d946-4a74-9bac-a55856d8b8e0'
project-slug: 'PerformanceMonitor'
signing-policy-slug: 'release-signing'
artifact-configuration-slug: 'Lite'
github-artifact-id: '${{ steps.upload-lite.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: 'signed/Lite'
- name: Sign Installer
if: github.event_name == 'release'
uses: signpath/github-action-submit-signing-request@v2
with:
api-token: '${{ secrets.SIGNPATH_API_TOKEN }}'
organization-id: '7969f8b6-d946-4a74-9bac-a55856d8b8e0'
project-slug: 'PerformanceMonitor'
signing-policy-slug: 'release-signing'
artifact-configuration-slug: 'Installers'
github-artifact-id: '${{ steps.upload-installer.outputs.artifact-id }}'
wait-for-completion: true
output-artifact-directory: 'signed/Installer'
- name: Replace with signed artifacts
if: github.event_name == 'release'
shell: pwsh
run: |
$version = "${{ steps.version.outputs.VERSION }}"
# Re-zip signed files into release archives
Remove-Item "releases/PerformanceMonitorDashboard-$version.zip" -ErrorAction SilentlyContinue
Compress-Archive -Path 'signed/Dashboard/*' -DestinationPath "releases/PerformanceMonitorDashboard-$version.zip" -Force
Remove-Item "releases/PerformanceMonitorLite-$version.zip" -ErrorAction SilentlyContinue
Compress-Archive -Path 'signed/Lite/*' -DestinationPath "releases/PerformanceMonitorLite-$version.zip" -Force
Remove-Item "releases/PerformanceMonitorInstaller-$version.zip" -ErrorAction SilentlyContinue
Compress-Archive -Path 'signed/Installer/*' -DestinationPath "releases/PerformanceMonitorInstaller-$version.zip" -Force
- name: Create Velopack release (Dashboard)
if: github.event_name == 'release'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
dotnet tool install -g vpk
New-Item -ItemType Directory -Force -Path releases/velopack-dashboard
New-Item -ItemType Directory -Force -Path releases/velopack-lite
# Dashboard: download previous + pack
vpk download github --repoUrl https://github.com/${{ github.repository }} --channel dashboard -o releases/velopack-dashboard --token $env:GH_TOKEN
vpk pack -u PerformanceMonitorDashboard -v $env:VERSION -p publish/Dashboard-velopack -e PerformanceMonitorDashboard.exe -o releases/velopack-dashboard --channel dashboard
# Lite: download previous + pack
vpk download github --repoUrl https://github.com/${{ github.repository }} --channel lite -o releases/velopack-lite --token $env:GH_TOKEN
vpk pack -u PerformanceMonitorLite -v $env:VERSION -p publish/Lite-velopack -e PerformanceMonitorLite.exe -o releases/velopack-lite --channel lite
- name: Generate checksums
if: github.event_name == 'release'
shell: pwsh
run: |
$checksums = Get-ChildItem releases/*.zip | ForEach-Object {
$hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLower()
"$hash $($_.Name)"
}
$checksums | Out-File -FilePath releases/SHA256SUMS.txt -Encoding utf8
Write-Host "Checksums:"
$checksums | ForEach-Object { Write-Host $_ }
- name: Upload release assets
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} releases/*.zip releases/SHA256SUMS.txt --clobber
- name: Upload Dashboard Velopack artifacts
if: github.event_name == 'release'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
vpk upload github --repoUrl https://github.com/${{ github.repository }} --channel dashboard -o releases/velopack-dashboard --releaseName "v$env:VERSION" --tag "v$env:VERSION" --merge --token $env:GH_TOKEN
- name: Upload Lite Velopack artifacts
if: github.event_name == 'release'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.VERSION }}
run: |
vpk upload github --repoUrl https://github.com/${{ github.repository }} --channel lite -o releases/velopack-lite --releaseName "v$env:VERSION" --tag "v$env:VERSION" --merge --token $env:GH_TOKEN