-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauto_upgrade_version.ps1
29 lines (22 loc) · 1.32 KB
/
auto_upgrade_version.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[string]$selected = Select-String '.\PSGitUtils\PSGitUtils.psd1' -Pattern 'ModuleVersion'
[string]$version = $selected.Split('''')[1]
[int[]]$numbers = $version.Split('.')
Write-Host "Current version is $version." -ForegroundColor Cyan
$options = [System.Management.Automation.Host.ChoiceDescription[]](
(New-Object System.Management.Automation.Host.ChoiceDescription "&major", "MAJOR version when you make incompatible API changes."),
(New-Object System.Management.Automation.Host.ChoiceDescription "m&inor", "MINOR version when you add functionality in a backwards compatible manner."),
(New-Object System.Management.Automation.Host.ChoiceDescription "&patch", "PATCH version when you make backwards compatible bug fixes.")
)
$chooseIndex = $Host.UI.PromptForChoice("Set new version", "Choose a label for generating new version.", $options, 2)
$numbers[$chooseIndex] = $numbers[$chooseIndex] + 1
if ($chooseIndex -eq 0) { # set minor and patch to 0
$numbers[1] = 0
$numbers[2] = 0
}
elseif ($chooseIndex -eq 1) { # set patch to 0
$numbers[2] = 0
}
$newVersion = $numbers -join '.'
(Get-Content '.\PSGitUtils\PSGitUtils.psd1').Replace($version, $newVersion) | Set-Content '.\PSGitUtils\PSGitUtils.psd1'
Write-Host "New version is $newVersion." -ForegroundColor Green
Write-Host "Update version successfully!" -ForegroundColor Green