forked from community-outpost/GenHub
-
Notifications
You must be signed in to change notification settings - Fork 0
368 lines (315 loc) · 13.3 KB
/
Copy pathci.yml
File metadata and controls
368 lines (315 loc) · 13.3 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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
name: GenHub CI
permissions:
contents: read
pull-requests: write
on:
push:
branches: [ main, development]
pull_request:
branches: [ main, development]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_VERSION: '8.0.x'
BUILD_CONFIGURATION: 'Release'
CORE_PROJECT: 'GenHub/GenHub.Core/GenHub.Core.csproj'
UI_PROJECT: 'GenHub/GenHub/GenHub.csproj'
WINDOWS_PROJECT: 'GenHub/GenHub.Windows/GenHub.Windows.csproj'
LINUX_PROJECT: 'GenHub/GenHub.Linux/GenHub.Linux.csproj'
TEST_PROJECTS: 'GenHub/GenHub.Tests/**/*.csproj'
jobs:
detect-changes:
name: Detect File Changes
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
core: ${{ steps.filter.outputs.core }}
ui: ${{ steps.filter.outputs.ui }}
windows: ${{ steps.filter.outputs.windows }}
linux: ${{ steps.filter.outputs.linux }}
tests: ${{ steps.filter.outputs.tests }}
any: ${{ steps.filter.outputs.any }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Filter Changed Paths
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
core:
- 'GenHub/GenHub.Core/**'
ui:
- 'GenHub/GenHub/**'
windows:
- 'GenHub/GenHub.Windows/**'
linux:
- 'GenHub/GenHub.Linux/**'
tests:
- 'GenHub/GenHub.Tests/**'
any:
- '**/*.cs'
- '**/*.axaml'
- '**/*.csproj'
- '**/*.sln'
- '.github/workflows/**'
- name: Changes Summary
run: |
echo "### 🔍 File Changes Summary" >> $GITHUB_STEP_SUMMARY
echo "- Core: ${{ steps.filter.outputs.core == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
echo "- UI: ${{ steps.filter.outputs.ui == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
echo "- Windows: ${{ steps.filter.outputs.windows == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
echo "- Linux: ${{ steps.filter.outputs.linux == 'true' && '✅' || '❌' }}" >> $GITHUB_STEP_SUMMARY
build-windows:
name: Build Windows
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.any == 'true' || needs.detect-changes.outputs.core == 'true' || needs.detect-changes.outputs.ui == 'true' || needs.detect-changes.outputs.windows == 'true' }}
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet Packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Extract Build Info
id: buildinfo
shell: pwsh
run: |
$shortHash = "${{ github.sha }}".Substring(0, 7)
$prNumber = "${{ github.event.pull_request.number }}"
$runNumber = "${{ github.run_number }}"
# Velopack requires SemVer2 3-part version (MAJOR.MINOR.PATCH)
# Using 0.0.X format to indicate alpha/pre-release status
if ($prNumber) {
$version = "0.0.$runNumber-pr$prNumber"
$channel = "PR"
} else {
$version = "0.0.$runNumber"
$channel = "CI"
}
Write-Host "Build Info:"
Write-Host " Short Hash: $shortHash"
Write-Host " PR Number: $prNumber"
Write-Host " Run Number: $runNumber"
Write-Host " Version: $version (SemVer2 for Velopack)"
Write-Host " Channel: $channel"
echo "SHORT_HASH=$shortHash" >> $env:GITHUB_OUTPUT
echo "PR_NUMBER=$prNumber" >> $env:GITHUB_OUTPUT
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
echo "CHANNEL=$channel" >> $env:GITHUB_OUTPUT
- name: Build Projects
shell: pwsh
run: |
$buildProps = @(
"-p:Version=${{ steps.buildinfo.outputs.VERSION }}"
"-p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }}"
"-p:PullRequestNumber=${{ steps.buildinfo.outputs.PR_NUMBER }}"
"-p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
)
Write-Host "Building Core project with build info"
dotnet build "${{ env.CORE_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
Write-Host "Building UI project"
dotnet build "${{ env.UI_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
Write-Host "Building Windows project"
dotnet build "${{ env.WINDOWS_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} @buildProps
- name: Publish Windows App
shell: pwsh
run: |
$buildProps = @(
"-p:Version=${{ steps.buildinfo.outputs.VERSION }}"
"-p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }}"
"-p:PullRequestNumber=${{ steps.buildinfo.outputs.PR_NUMBER }}"
"-p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
)
Write-Host "Publishing Windows application"
Write-Host "Version: ${{ steps.buildinfo.outputs.VERSION }}"
dotnet publish "${{ env.WINDOWS_PROJECT }}" `
-c ${{ env.BUILD_CONFIGURATION }} `
-r win-x64 `
--self-contained true `
-o "win-publish" `
@buildProps
- name: Install Velopack CLI
run: dotnet tool install -g vpk
- name: Create Velopack Package
shell: pwsh
run: |
Write-Host "Creating Velopack package..."
vpk pack `
--packId GenHub `
--packVersion ${{ steps.buildinfo.outputs.VERSION }} `
--packDir win-publish `
--mainExe GenHub.Windows.exe `
--packTitle "GenHub" `
--packAuthors "Community Outpost" `
--icon GenHub/GenHub/Assets/Icons/generalshub.ico `
--outputDir velopack-release
Write-Host "Velopack artifacts created:"
Get-ChildItem -Path "velopack-release" -Recurse | Select-Object Name, Length
- name: Run Tests
id: tests
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$testProjects = Get-ChildItem -Path "GenHub/GenHub.Tests" -Recurse -Filter *.csproj | Where-Object { $_.Name -notlike '*Linux*' }
if ($testProjects) {
foreach ($testProject in $testProjects) {
Write-Host "Testing $($testProject.FullName)"
dotnet test $testProject.FullName -c $env:BUILD_CONFIGURATION
if ($LASTEXITCODE -ne 0) {
throw "Test failed for $($testProject.FullName)"
}
}
} else {
Write-Host "No test projects found."
}
- name: Upload Velopack Update Package (.nupkg)
uses: actions/upload-artifact@v4
with:
name: genhub-velopack-windows-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release/*.nupkg
if-no-files-found: error
retention-days: 30
- name: Upload Velopack Setup Installer
uses: actions/upload-artifact@v4
with:
name: genhub-setup-windows-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release/*-Setup.exe
if-no-files-found: error
retention-days: 30
- name: Upload Velopack Metadata
uses: actions/upload-artifact@v4
with:
name: genhub-metadata-windows-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release/RELEASES
if-no-files-found: error
retention-days: 30
build-linux:
name: Build Linux
needs: detect-changes
if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.any == 'true' || needs.detect-changes.outputs.core == 'true' || needs.detect-changes.outputs.ui == 'true' || needs.detect-changes.outputs.linux == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Install Linux Dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libx11-dev
- name: Cache NuGet Packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Extract Build Info
id: buildinfo
run: |
SHORT_HASH=$(echo "${{ github.sha }}" | cut -c1-7)
PR_NUMBER="${{ github.event.pull_request.number }}"
RUN_NUMBER="${{ github.run_number }}"
# Velopack requires SemVer2 3-part version (MAJOR.MINOR.PATCH)
# Using 0.0.X format to indicate alpha/pre-release status
if [ -n "$PR_NUMBER" ]; then
VERSION="0.0.${RUN_NUMBER}-pr${PR_NUMBER}"
CHANNEL="PR"
else
VERSION="0.0.${RUN_NUMBER}"
CHANNEL="CI"
fi
echo "Build Info:"
echo " Short Hash: $SHORT_HASH"
echo " PR Number: $PR_NUMBER"
echo " Run Number: $RUN_NUMBER"
echo " Version: $VERSION (SemVer2 for Velopack)"
echo " Channel: $CHANNEL"
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_OUTPUT
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build Projects
run: |
BUILD_PROPS="-p:Version=${{ steps.buildinfo.outputs.VERSION }} -p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }} -p:PullRequestNumber=${{ steps.buildinfo.outputs.PR_NUMBER }} -p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
echo "Building Core project with build info"
dotnet build "${{ env.CORE_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} $BUILD_PROPS
echo "Building UI project"
dotnet build "${{ env.UI_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} $BUILD_PROPS
echo "Building Linux project"
dotnet build "${{ env.LINUX_PROJECT }}" -c ${{ env.BUILD_CONFIGURATION }} $BUILD_PROPS
- name: Publish Linux App
run: |
BUILD_PROPS="-p:Version=${{ steps.buildinfo.outputs.VERSION }} -p:GitShortHash=${{ steps.buildinfo.outputs.SHORT_HASH }} -p:PullRequestNumber=${{ steps.buildinfo.outputs.PR_NUMBER }} -p:BuildChannel=${{ steps.buildinfo.outputs.CHANNEL }}"
echo "Publishing Linux application"
dotnet publish "${{ env.LINUX_PROJECT }}" \
-c ${{ env.BUILD_CONFIGURATION }} \
-r linux-x64 \
--self-contained true \
-o "linux-publish" \
$BUILD_PROPS
- name: Install Velopack CLI
run: dotnet tool install -g vpk
- name: Create Velopack Package
run: |
echo "Creating Velopack package..."
vpk pack \
--packId GenHub \
--packVersion ${{ steps.buildinfo.outputs.VERSION }} \
--packDir linux-publish \
--mainExe GenHub.Linux \
--packTitle "GenHub" \
--packAuthors "Community Outpost" \
--icon GenHub/GenHub/Assets/Icons/generalshub-icon.png \
--outputDir velopack-release
echo "Velopack artifacts created:"
ls -lh velopack-release/
- name: Run Tests
run: |
shopt -s globstar nullglob
for test_project in ${{ env.TEST_PROJECTS }}; do
[[ "$test_project" == *Windows* ]] && continue
echo "Testing $test_project"
dotnet test "$test_project" -c ${{ env.BUILD_CONFIGURATION }} --verbosity normal
done
- name: Upload Velopack Update Package (.nupkg)
uses: actions/upload-artifact@v4
with:
name: genhub-velopack-linux-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release/*.nupkg
if-no-files-found: error
retention-days: 30
- name: Upload Velopack Metadata
uses: actions/upload-artifact@v4
with:
name: genhub-metadata-linux-${{ steps.buildinfo.outputs.VERSION }}
path: velopack-release/releases.*.json
if-no-files-found: error
retention-days: 30
summary:
name: Build Summary
needs: [build-windows, build-linux]
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Generate Summary
run: |
echo "### 🚀 GenHub Build Results" >> $GITHUB_STEP_SUMMARY
echo "| Platform | Status |" >> $GITHUB_STEP_SUMMARY
echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
echo "| Windows | ${{ needs.build-windows.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Linux | ${{ needs.build-linux.result == 'success' && '✅ Passed' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY