1
1
$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 ]
5
7
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
7
18
$newRevision = [int ]$currentDate.DayOfYear * 24 + $currentDate.Day + $currentDate.Hour + $currentDate.Minute
19
+ $newVersion = New-Object System.Version($major , $minor , $build , $revision )
8
20
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
11
23
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