2017-10-26 21:15:56 +03:00
<#
. SYNOPSIS
Bumps the version number of GitHub for Visual Studio
. DESCRIPTION
By default , just bumps the last component of the version number by one . An
alternate version number can be specified on the command line .
The new version number is committed to the local repository and pushed to
GitHub .
#>
Param (
# It would be nice to use our Validate-Version function here, but we
# can't because this Param definition has to come before any other code in the
# file.
2017-10-28 19:57:41 +03:00
[ ValidateScript ( { ( $_ . Major -ge 0 ) -and ( $_ . Minor -ge 0 ) -and ( $_ . Build -ge 0 ) } ) ]
2017-10-26 21:15:56 +03:00
[ System.Version ]
$NewVersion = $null
,
[ switch ]
$BumpMajor = $false
,
[ switch ]
$BumpMinor = $false
,
[ switch ]
$BumpPatch = $false
,
2017-10-31 05:09:45 +03:00
[ switch ]
$BumpBuild = $false
2017-10-26 21:15:56 +03:00
,
2017-11-01 03:27:04 +03:00
[ int ]
$BuildNumber = -1
,
2017-10-26 21:15:56 +03:00
[ switch ]
2017-10-31 05:09:45 +03:00
$Commit = $false
2017-10-26 21:15:56 +03:00
,
[ switch ]
2017-10-31 05:09:45 +03:00
$Push = $false
,
[ switch ]
2017-10-26 21:15:56 +03:00
$Force = $false
2017-10-31 05:09:45 +03:00
,
[ switch ]
$Trace = $false
2017-10-26 21:15:56 +03:00
)
Set-StrictMode -Version Latest
2017-10-31 05:09:45 +03:00
if ( $Trace ) { Set-PSDebug -Trace 1 }
2017-10-26 21:15:56 +03:00
2017-10-31 05:09:45 +03:00
. $PSScriptRoot \ modules . ps1 | out-null
2017-11-01 23:58:10 +03:00
. $scriptsDirectory \ Modules \ Versioning . ps1 | out-null
2017-10-31 05:09:45 +03:00
. $scriptsDirectory \ Modules \ Vsix . ps1 | out-null
. $scriptsDirectory \ Modules \ SolutionInfo . ps1 | out-null
2017-11-01 23:58:10 +03:00
. $scriptsDirectory \ Modules \ AppVeyor . ps1 | out-null
2018-08-23 16:54:07 +03:00
. $scriptsDirectory \ Modules \ DirectoryBuildProps . ps1 | out-null
2017-10-26 21:15:56 +03:00
2017-11-01 03:27:04 +03:00
if ( $NewVersion -eq $null ) {
if ( ! $BumpMajor -and ! $BumpMinor -and ! $BumpPatch -and ! $BumpBuild ) {
Die -1 " You need to indicate which part of the version to update via -BumpMajor/-BumpMinor/-BumpPatch/-BumpBuild flags or a custom version via -NewVersion "
}
}
2017-10-31 05:09:45 +03:00
if ( $Push -and ! $Commit ) {
Die 1 " Cannot push a version bump without -Commit "
2017-10-26 21:15:56 +03:00
}
2017-10-31 05:09:45 +03:00
if ( $Commit -and ! $Force ) {
Require-CleanWorkTree " bump version "
2017-10-26 21:15:56 +03:00
}
2017-10-31 05:09:45 +03:00
if ( ! $ ? ) {
exit 1
2017-10-26 21:15:56 +03:00
}
2017-10-31 05:09:45 +03:00
if ( $NewVersion -eq $null ) {
2017-11-01 23:58:10 +03:00
$currentVersion = Read-Version
2017-11-01 03:27:04 +03:00
$NewVersion = Generate-Version $currentVersion $BumpMajor $BumpMinor $BumpPatch $BumpBuild $BuildNumber
2017-10-26 21:15:56 +03:00
}
2017-11-01 03:27:04 +03:00
Write-Output " Setting version to $NewVersion "
2017-10-31 05:09:45 +03:00
Write-Version $NewVersion
2017-10-26 21:15:56 +03:00
2017-10-31 05:09:45 +03:00
if ( $Commit ) {
2017-11-01 03:27:04 +03:00
Write-Output " Committing version change "
2017-10-31 05:09:45 +03:00
Commit-Version $NewVersion
2017-10-26 21:15:56 +03:00
2017-10-31 05:09:45 +03:00
if ( $Push ) {
2017-11-01 03:27:04 +03:00
Write-Output " Pushing version change "
2017-10-31 05:09:45 +03:00
$branch = & $git rev-parse - -abbrev -ref HEAD
Push-Changes $branch
2017-10-26 21:15:56 +03:00
}
}