-
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): fix dev version calculation
- Loading branch information
Showing
1 changed file
with
20 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |