Skip to content

Commit 81253d4

Browse files
authored
fix(ci): fix dev version calculation
1 parent 0bf93e6 commit 81253d4

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

devVersion.ps1

+20-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
$latestTag = git describe --tags --abbrev=0
2-
$currentVersion = [Version]$latestTag.substring(1)
3-
$scriptPath = $MyInvocation.MyCommand.Path
4-
$scriptFolder = Split-Path $scriptPath -Parent
2+
# Split the version string into major, minor, build, and revision components
3+
$versionParts = $latestTag.Split('.')
4+
$major = $versionParts[0]
5+
$minor = $versionParts[1]
6+
$build = $versionParts[2]
57

6-
$currentDate = (Get-Date)
8+
# Handle the beta version separately
9+
if ($versionParts.Length -gt 3) {
10+
# Assuming the beta version follows the pattern 'major.minor.build-beta'
11+
$revision = $versionParts[3].Split('-')[0] # Extract the numeric part before '-beta'
12+
} else {
13+
# No beta version, so use the last part as the revision
14+
$revision = $versionParts[3]
15+
}
16+
17+
# Construct the new version with the calculated revision
718
$newRevision = [int]$currentDate.DayOfYear * 24 + $currentDate.Day + $currentDate.Hour + $currentDate.Minute
19+
$newVersion = New-Object System.Version($major, $minor, $build, $revision)
820

9-
$newVersion = [Version]::new($currentVersion.Major, $currentVersion.Minor, $currentVersion.Build, $newRevision)
10-
(Get-Content SoundSwitch/Properties/AssemblyInfo.cs) -replace "AssemblyVersion\(.+\)","AssemblyVersion(`"$newVersion`")" | Out-File SoundSwitch/Properties/AssemblyInfo.cs
21+
# Replace the AssemblyVersion in AssemblyInfo.cs
22+
(Get-Content SoundSwitch/Properties/AssemblyInfo.cs) -replace "AssemblyVersion\(.+\)", "AssemblyVersion(`"$newVersion`")" | Set-Content SoundSwitch/Properties/AssemblyInfo.cs
1123

12-
"version=$($newVersion.toString())" | Out-File $Env:GITHUB_OUTPUT
24+
# Output the new version to GITHUB_OUTPUT
25+
"version=$($newVersion.ToString())" | Set-Content $Env:GITHUB_OUTPUT

0 commit comments

Comments
 (0)