-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (237 loc) · 12 KB
/
ci.yml
File metadata and controls
277 lines (237 loc) · 12 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
name: CI Build
on:
push:
branches: [main]
# pull_request:
# branches: [main]
permissions:
contents: write # Required for creating draft releases
env:
VERSION: '' # Will be set from package.json (expects 4-part Major.Minor.Build.Revision)
BUILD_MSIX: 'false' # Set to 'true' to enable MSIX package build
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from package.json
id: get_version
shell: pwsh
run: |
$packageJson = Get-Content -Path "package.json" -Raw | ConvertFrom-Json
$version = $packageJson.version
Write-Host "Version from package.json: $version"
echo "VERSION=$version" >> $env:GITHUB_ENV
echo "version=$version" >> $env:GITHUB_OUTPUT
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install WiX Toolset
shell: pwsh
run: |
dotnet tool install --global wix --version 4.0.5
wix --version
- name: Restore dependencies
run: |
dotnet restore Src/GhostDraw/GhostDraw.csproj
dotnet restore Tests/GhostDraw.Tests/GhostDraw.Tests.csproj
- name: Build application and tests
run: |
dotnet build Src/GhostDraw/GhostDraw.csproj -c Release --no-restore
dotnet build Tests/GhostDraw.Tests/GhostDraw.Tests.csproj -c Release --no-restore
- name: Run tests
run: dotnet test Tests/GhostDraw.Tests/GhostDraw.Tests.csproj -c Release --no-build --verbosity normal
- name: Publish application
shell: pwsh
run: |
dotnet publish Src/GhostDraw/GhostDraw.csproj `
-c Release `
-r win-x64 `
--self-contained true `
-p:PublishSingleFile=false `
-p:Version=${{ env.VERSION }}
- name: Generate WiX component list
shell: pwsh
working-directory: Installer
run: |
.\Generate-FileList.ps1 `
-PublishPath "..\Src\GhostDraw\bin\Release\net8.0-windows\win-x64\publish" `
-OutputFile "HarvestedFiles.wxs"
- name: Build installer MSI
shell: pwsh
working-directory: Installer
run: |
dotnet build GhostDraw.Installer.wixproj `
-c Release `
-p:Version=${{ env.VERSION }} `
-p:PublishDir="..\Src\GhostDraw\bin\Release\net8.0-windows\win-x64\publish\"
- name: Verify build outputs
shell: pwsh
run: |
$exePath = "Src\GhostDraw\bin\Release\net8.0-windows\win-x64\publish\GhostDraw.exe"
$msiPath = "Installer\bin\x64\Release\GhostDrawSetup-${{ env.VERSION }}.msi"
if (Test-Path $exePath) {
Write-Host "✓ Application EXE built successfully" -ForegroundColor Green
} else {
Write-Error "Application EXE not found"
exit 1
}
if (Test-Path $msiPath) {
$size = (Get-Item $msiPath).Length / 1MB
Write-Host "✓ Installer MSI built successfully (${{ env.VERSION }})" -ForegroundColor Green
Write-Host " Size: $([math]::Round($size, 2)) MB" -ForegroundColor Gray
} else {
Write-Error "Installer MSI not found at $msiPath"
exit 1
}
# ============================================================
# MSIX Package Build (Optional - Controlled by BUILD_MSIX env var)
# ============================================================
- name: Setup MSBuild
if: env.BUILD_MSIX == 'true'
uses: microsoft/setup-msbuild@v2
- name: Build MSIX package
if: env.BUILD_MSIX == 'true'
shell: pwsh
run: |
Write-Host "Building MSIX package for Microsoft Store..." -ForegroundColor Cyan
# MSBuild is now in PATH thanks to setup-msbuild action
# Build MSIX (unsigned for CI - Store will sign it)
msbuild Package\GhostDraw.Package.wapproj `
/p:Configuration=Release `
/p:Platform=x64 `
/p:AppxBundle=Never `
/p:UapAppxPackageBuildMode=SideloadOnly `
/p:AppxPackageSigningEnabled=false `
/p:GenerateAppInstallerFile=false
if ($LASTEXITCODE -ne 0) {
Write-Error "MSIX build failed"
exit 1
}
- name: Verify MSIX build output
if: env.BUILD_MSIX == 'true'
shell: pwsh
run: |
$msixPath = "Package\AppPackages\GhostDraw.Package_${{ env.VERSION }}_Test\GhostDraw.Package_${{ env.VERSION }}_x64.msix"
if (Test-Path $msixPath) {
$size = (Get-Item $msixPath).Length / 1MB
Write-Host "✓ MSIX package built successfully" -ForegroundColor Green
Write-Host " Path: $msixPath" -ForegroundColor Gray
Write-Host " Size: $([math]::Round($size, 2)) MB" -ForegroundColor Gray
} else {
Write-Error "MSIX package not found at $msixPath"
exit 1
}
# ============================================================
# End MSIX Build
# ============================================================
- name: Create portable zip
shell: pwsh
run: |
$publishDir = "Src\GhostDraw\bin\Release\net8.0-windows\win-x64\publish"
$zipPath = "GhostDraw-${{ env.VERSION }}-portable.zip"
Compress-Archive -Path "$publishDir\*" -DestinationPath $zipPath -Force
$size = (Get-Item $zipPath).Length / 1MB
Write-Host "✓ Portable ZIP created: $zipPath" -ForegroundColor Green
Write-Host " Size: $([math]::Round($size, 2)) MB" -ForegroundColor Gray
- name: Delete old artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: |
GhostDrawSetup-*
GhostDraw-*-portable
GhostDraw-*-MSIX
failOnError: false
- name: Upload installer artifact
uses: actions/upload-artifact@v4
with:
name: GhostDrawSetup-${{ env.VERSION }}
path: Installer/bin/x64/Release/GhostDrawSetup-${{ env.VERSION }}.msi
retention-days: 30
- name: Upload portable artifact
uses: actions/upload-artifact@v4
with:
name: GhostDraw-${{ env.VERSION }}-portable
path: GhostDraw-${{ env.VERSION }}-portable.zip
retention-days: 30
# - name: Upload MSIX artifact
# if: env.BUILD_MSIX == 'true'
# uses: actions/upload-artifact@v4
# with:
# name: GhostDraw-${{ env.VERSION }}-MSIX
# path: Package/AppPackages/GhostDraw.Package_${{ env.VERSION }}_Test/*.msix
# retention-days: 30
# Check if a PUBLISHED (non-draft) release exists for this version
# If only a draft exists, we should update it with new assets
- name: Check if published release exists
id: check_release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$tagName = "v${{ env.VERSION }}"
# Try to get release info, capture result
try {
$release = gh release view $tagName --json isDraft,name 2>$null
if ($LASTEXITCODE -eq 0 -and $release) {
$releaseInfo = $release | ConvertFrom-Json
if ($releaseInfo.isDraft -eq $true) {
Write-Host "Draft release exists for $tagName - will update with new assets"
"skip_release=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
} else {
Write-Host "Published release exists for $tagName - skipping"
"skip_release=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
} else {
Write-Host "No release exists for $tagName - will create draft release"
"skip_release=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
} catch {
Write-Host "No release exists for $tagName - will create draft release"
"skip_release=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
}
# Always exit successfully
exit 0
- name: Prepare release files list
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_release.outputs.skip_release == 'false'
id: release_files
shell: pwsh
run: |
$files = @(
"Installer/bin/x64/Release/GhostDrawSetup-${{ env.VERSION }}.msi",
"GhostDraw-${{ env.VERSION }}-portable.zip"
)
if ($env:BUILD_MSIX -eq 'true') {
$files += "Package/AppPackages/GhostDraw.Package_${{ env.VERSION }}_Test/GhostDraw.Package_${{ env.VERSION }}_x64.msix"
}
$filesList = $files -join "`n"
"files<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
$filesList | Out-File -FilePath $env:GITHUB_OUTPUT -Append
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Create or update draft release
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.check_release.outputs.skip_release == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: GhostDraw v${{ env.VERSION }}
draft: true
prerelease: false
generate_release_notes: true
files: ${{ steps.release_files.outputs.files }}
body: |
## GhostDraw v${{ env.VERSION }}
### Downloads
- **GhostDrawSetup-${{ env.VERSION }}.msi** - Windows installer (recommended)
- **GhostDraw-${{ env.VERSION }}-portable.zip** - Portable version (no installation required)
${{ env.BUILD_MSIX == 'true' && format('- **GhostDraw.Package_{0}_x64.msix** - Microsoft Store package (unsigned - for testing only)', env.VERSION) || '' }}
### Installation
1. Download the MSI installer or portable ZIP
2. Run the installer or extract the ZIP to a folder of your choice
3. Launch GhostDraw from the Start Menu or the extracted folder
---
*Edit this draft to add release notes, then publish when ready.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}