Skip to content

Commit cea1e6a

Browse files
committed
fix: ci workflow
1 parent fd8617d commit cea1e6a

6 files changed

Lines changed: 67 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ jobs:
2626
wix --version
2727
2828
- name: Restore dependencies
29-
run: dotnet restore GhostDraw.sln
29+
run: |
30+
dotnet restore Src/GhostDraw/GhostDraw.csproj
31+
dotnet restore Tests/GhostDraw.Tests/GhostDraw.Tests.csproj
3032
3133
- name: Build application and tests
32-
run: dotnet build GhostDraw.sln -c Release --no-restore
34+
run: |
35+
dotnet build Src/GhostDraw/GhostDraw.csproj -c Release --no-restore
36+
dotnet build Tests/GhostDraw.Tests/GhostDraw.Tests.csproj -c Release --no-restore
3337
3438
- name: Run tests
35-
run: dotnet test GhostDraw.sln -c Release --no-build --verbosity normal
39+
run: dotnet test Tests/GhostDraw.Tests/GhostDraw.Tests.csproj -c Release --no-build --verbosity normal
3640

3741
- name: Publish application
3842
shell: pwsh

Installer/GhostDraw.Installer.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="WixToolset.Sdk/4.0.5">
22
<PropertyGroup>
3-
<Version Condition="'$(Version)' == ''">1.0.0</Version>
3+
<Version Condition="'$(Version)' == ''">1.0.2</Version>
44
<OutputName>GhostDrawSetup-$(Version)</OutputName>
55
<OutputType>Package</OutputType>
66
<Platform>x64</Platform>

Scripts/Update-Version.ps1

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ function Get-LatestGitTag {
4747
Write-Host "Fetching latest tags from remote..." -ForegroundColor Yellow
4848
git fetch --tags 2>&1 | Out-Null
4949

50-
# Get the latest tag (sorted by version)
51-
$latestTag = git describe --tags --abbrev=0 2>&1
50+
# Get the latest tag sorted by version number (descending)
51+
# Using -v:refname ensures proper semantic version sorting
52+
$latestTag = git tag -l --sort=-v:refname | Select-Object -First 1
5253

53-
if ($LASTEXITCODE -ne 0) {
54+
if (-not $latestTag) {
5455
throw "No git tags found in repository"
5556
}
5657

@@ -115,7 +116,7 @@ function Update-PackageJson {
115116
return $true
116117
}
117118

118-
# Function to update .csproj file
119+
# Function to update .csproj file (simple <Version> element)
119120
function Update-CsprojFile {
120121
param(
121122
[string]$FilePath,
@@ -157,6 +158,49 @@ function Update-CsprojFile {
157158
return $true
158159
}
159160

161+
# Function to update WiX project file (conditional <Version> element)
162+
function Update-WixProjFile {
163+
param(
164+
[string]$FilePath,
165+
[string]$NewVersion,
166+
[switch]$DryRun
167+
)
168+
169+
if (-not (Test-Path $FilePath)) {
170+
Write-Warning "File not found: $FilePath"
171+
return $false
172+
}
173+
174+
$content = Get-Content $FilePath -Raw
175+
$fileName = Split-Path $FilePath -Leaf
176+
177+
# Match Version element with Condition attribute (WiX default version pattern)
178+
# Pattern: <Version Condition="'$(Version)' == ''">X.Y.Z</Version>
179+
if ($content -notmatch '<Version\s+Condition="[^"]*">([^<]*)</Version>') {
180+
Write-Warning " $fileName`: No conditional <Version> element found"
181+
return $false
182+
}
183+
184+
$oldVersion = $Matches[1]
185+
186+
if ($oldVersion -eq $NewVersion) {
187+
Write-Host " $fileName`: Already at version $NewVersion" -ForegroundColor Green
188+
return $true
189+
}
190+
191+
if ($DryRun) {
192+
Write-Host " $fileName`: Would update $oldVersion -> $NewVersion" -ForegroundColor Yellow
193+
return $true
194+
}
195+
196+
# Update version while preserving the Condition attribute
197+
$updatedContent = $content -replace '(<Version\s+Condition="[^"]*">)[^<]*(</Version>)', "`${1}$NewVersion`${2}"
198+
199+
Set-Content -Path $FilePath -Value $updatedContent -NoNewline
200+
Write-Host " $fileName`: Updated $oldVersion -> $NewVersion" -ForegroundColor Green
201+
return $true
202+
}
203+
160204
# Main execution
161205
try {
162206
Write-Host ""
@@ -192,6 +236,10 @@ try {
192236
@{
193237
Path = Join-Path $RepoRoot "Src\GhostDraw\GhostDraw.csproj"
194238
Type = "Csproj"
239+
},
240+
@{
241+
Path = Join-Path $RepoRoot "Installer\GhostDraw.Installer.wixproj"
242+
Type = "WixProj"
195243
}
196244
)
197245

@@ -206,6 +254,9 @@ try {
206254
"Csproj" {
207255
$result = Update-CsprojFile -FilePath $file.Path -NewVersion $version -DryRun:$DryRun
208256
}
257+
"WixProj" {
258+
$result = Update-WixProjFile -FilePath $file.Path -NewVersion $version -DryRun:$DryRun
259+
}
209260
}
210261
if (-not $result) {
211262
$success = $false

Src/GhostDraw/GhostDraw.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>WinExe</OutputType>
@@ -8,7 +8,7 @@
88
<UseWPF>true</UseWPF>
99
<UseWindowsForms>true</UseWindowsForms>
1010
<ApplicationIcon>Assets\favicon.ico</ApplicationIcon>
11-
<Version>1.0.1</Version>
11+
<Version>1.0.2</Version>
1212
</PropertyGroup>
1313

1414
<ItemGroup>

installer/GhostDraw.Installer.wixproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="WixToolset.Sdk/4.0.5">
22
<PropertyGroup>
3-
<Version Condition="'$(Version)' == ''">1.0.0</Version>
3+
<Version Condition="'$(Version)' == ''">1.0.2</Version>
44
<OutputName>GhostDrawSetup-$(Version)</OutputName>
55
<OutputType>Package</OutputType>
66
<Platform>x64</Platform>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ghost-draw",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "Draw directly on your screen with a transparent overlay",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)