Skip to content

Commit

Permalink
fix(ci): fix dev version calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Belphemur committed May 21, 2024
1 parent 0bf93e6 commit 81253d4
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions devVersion.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
$latestTag = git describe --tags --abbrev=0
$currentVersion = [Version]$latestTag.substring(1)
$scriptPath = $MyInvocation.MyCommand.Path
$scriptFolder = Split-Path $scriptPath -Parent
# Split the version string into major, minor, build, and revision components
$versionParts = $latestTag.Split('.')
$major = $versionParts[0]
$minor = $versionParts[1]
$build = $versionParts[2]

$currentDate = (Get-Date)
# Handle the beta version separately
if ($versionParts.Length -gt 3) {
# Assuming the beta version follows the pattern 'major.minor.build-beta'
$revision = $versionParts[3].Split('-')[0] # Extract the numeric part before '-beta'
} else {
# No beta version, so use the last part as the revision
$revision = $versionParts[3]
}

# Construct the new version with the calculated revision
$newRevision = [int]$currentDate.DayOfYear * 24 + $currentDate.Day + $currentDate.Hour + $currentDate.Minute
$newVersion = New-Object System.Version($major, $minor, $build, $revision)

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

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

0 comments on commit 81253d4

Please sign in to comment.