Skip to content

Instantly share code, notes, and snippets.

@derantell
Last active June 3, 2016 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derantell/b8a4c87ea50177b900379df92a25de9d to your computer and use it in GitHub Desktop.
Save derantell/b8a4c87ea50177b900379df92a25de9d to your computer and use it in GitHub Desktop.
Powershell semver bump function
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