Last active
June 3, 2016 08:38
-
-
Save derantell/b8a4c87ea50177b900379df92a25de9d to your computer and use it in GitHub Desktop.
Powershell semver bump function
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
function bumpVersion { | |
param ( $v, $part = 'patch' ) | |
$v -match '^(\d+)\.(\d+)\.(\d+)(.*)$' | out-null | |
$major, $minor, $patch, $rest = [int]$matches[1], [int]$matches[2], [int]$matches[3], $matches[4] | |
switch ($part) { | |
'major' { $major += 1; $minor = 0; $patch = 0 } | |
'minor' { $minor += 1; $patch = 0 } | |
'patch' { $patch += 1 } | |
} | |
"$major.$minor.$patch$rest" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment