Created
June 18, 2017 23:13
-
-
Save JasonMorgan/e18f181d1dbe2523f99e11d3339e6244 to your computer and use it in GitHub Desktop.
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
enum bump { | |
Major | |
Minor | |
Patch | |
} | |
function Update-CookbookVersion { | |
param ( | |
[string]$path, | |
[bump]$bump = 'Patch' | |
) | |
$string = Get-Content -Path $path -Raw | |
[version]$version = $string.Split("`n").Where{$_ -match 'version'}.Split("'")[1] | |
switch ($bump) { | |
'Major' { | |
$new = ($version.Major + 1), $version.Minor, $version.Build -join '.' | |
} | |
'Minor' { | |
$new = $version.Major, ($version.Minor + 1), $version.Build -join '.' | |
} | |
'Patch' { | |
$new = $version.Major, $version.Minor, ($version.Build + 1) -join '.' | |
} | |
} | |
$new = "version '$new'" | |
($string -replace "version '.*'", $new).Split("`n").Where{$_.length -gt 1} > $path | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment