-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-version.ps1
53 lines (46 loc) · 997 Bytes
/
update-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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[CmdletBinding(PositionalBinding = $false)]
Param
(
[Parameter(Mandatory = $true)]
[ValidateScript({
Test-Path $_ -PathType leaf -Include '*.psd1'
})]
[string]
$Path,
$Major,
$Minor,
$Build,
$Revision,
[switch]
$IncrementMinor,
[switch]
$IncrimentMajor
)
$Module = Test-ModuleManifest -Path $Path
$Major = switch ($Major) {
$null { $Module.Version.Major }
default { $Major }
}
$Minor = switch ($Minor) {
$null { $Module.Version.Minor }
default { $Minor }
}
$Build = switch ($Build) {
$null { $Module.Version.Build }
default { $Build }
}
$Revision = switch ($Revision) {
$null { $Module.Version.Revision }
default { $Revision }
}
if ($IncrimentMajor) {
$Major++
}
if ($IncrementMinor) {
$Minor++
}
$version = switch ($Revision) {
-1 { New-Object System.Version -ArgumentList $Major, $Minor, $Build }
default { New-Object System.Version -ArgumentList $Major, $Minor, $Build, $Revision }
}
Update-ModuleManifest -Path $Path -ModuleVersion $version