|
13 | 13 |
|
14 | 14 | #> |
15 | 15 |
|
16 | | -function Update-ReadmeVersion([string]$readmeFilePath, [string]$version) { |
| 16 | +function Update-ReadmeVersion([string]$readmeFilePath, [version]$version) { |
17 | 17 | $readmeFileContent = Get-Content -Path $readmeFilePath -Raw |
18 | | - $readmeFileContent = $readmeFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version |
| 18 | + $readmeFileContent = $readmeFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version.ToString() |
19 | 19 | Set-Content -Path $readmeFilePath $readmeFileContent |
20 | 20 | } |
21 | 21 |
|
22 | | -function Update-TelemetryVersion([string]$telemetryFilePath, [string]$version) { |
| 22 | +function Update-TelemetryVersion([string]$telemetryFilePath, [version]$version) { |
23 | 23 | $telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw |
24 | | - $telemetryFileContent = $telemetryFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version |
| 24 | + $telemetryFileContent = $telemetryFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version.ToString() |
25 | 25 | Set-Content -Path $telemetryFilePath $telemetryFileContent |
26 | 26 | } |
27 | 27 |
|
28 | | -function Update-PackageVersion([string]$propertiesFilePath, [string]$version) { |
| 28 | +function Update-PackageVersion([string]$propertiesFilePath, [version]$version) { |
29 | 29 | $propertiesFileContent = Get-Content -Path $propertiesFilePath -Raw |
30 | | - if($version -match "(\d{1,})\.(\d{1,})\.(\d{1,})") { |
31 | | - $patch = $Matches[3] |
32 | | - $minor = $Matches[2] |
33 | | - $major = $Matches[1] |
34 | | - $propertiesFileContent = $propertiesFileContent -replace "mavenMajorVersion\s+=\s+\d{1,}", "mavenMajorVersion = $major" |
35 | | - $propertiesFileContent = $propertiesFileContent -replace "mavenMinorVersion\s+=\s+\d{1,}", "mavenMinorVersion = $minor" |
36 | | - $propertiesFileContent = $propertiesFileContent -replace "mavenPatchVersion\s+=\s+\d{1,}", "mavenPatchVersion = $patch" |
37 | | - Set-Content -Path $propertiesFilePath $propertiesFileContent |
38 | | - } else { |
39 | | - Write-Error "Invalid version number format $version" |
40 | | - } |
| 30 | + $propertiesFileContent = $propertiesFileContent -replace "mavenMajorVersion\s+=\s+\d{1,}", "mavenMajorVersion = $($version.Major)" |
| 31 | + $propertiesFileContent = $propertiesFileContent -replace "mavenMinorVersion\s+=\s+\d{1,}", "mavenMinorVersion = $($version.Minor)" |
| 32 | + $propertiesFileContent = $propertiesFileContent -replace "mavenPatchVersion\s+=\s+\d{1,}", "mavenPatchVersion = $($version.Build)" |
| 33 | + Set-Content -Path $propertiesFilePath $propertiesFileContent |
41 | 34 | } |
42 | 35 | function Get-CurrentTelemetryVersion([string]$telemetryFilePath) { |
43 | 36 | $telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw |
44 | 37 | if($telemetryFileContent -match "(\d{1,}\.\d{1,}\.\d{1,})") { |
45 | | - return $Matches[1] |
| 38 | + return [version]::Parse($Matches[1]) |
46 | 39 | } else { |
47 | 40 | Write-Error "Invalid version number format" |
48 | | - return "" |
| 41 | + return $null; |
49 | 42 | } |
50 | 43 | } |
51 | 44 |
|
52 | | -function Update-MinorVersionNumber([string]$currentVersion) { |
53 | | - if($currentVersion -match "(\d{1,})\.(\d{1,})\.(\d{1,})") { |
54 | | - [int]$minor = [convert]::ToInt32($Matches[2]) |
55 | | - $minor++; |
56 | | - $major = $Matches[1] |
57 | | - return "$major.$minor.0" |
58 | | - } else { |
59 | | - Write-Error "Invalid version number format $currentVersion" |
60 | | - return "" |
61 | | - } |
| 45 | +function Update-MinorVersionNumber([version]$currentVersion) { |
| 46 | + return [version]::new($currentVersion.Major, $currentVersion.Minor + 1, 0); |
62 | 47 | } |
63 | 48 |
|
64 | 49 | function Update-MinorVersion() { |
|
0 commit comments