Permalink
Browse files

Adds support for automatically bumping module versions and PrepareRel…

…ease task
  • Loading branch information...
1 parent 37816d9 commit e051c00b430abb3f390ccdb379fab48bdc5cd775 @chelnak chelnak committed Dec 19, 2016
Showing with 45 additions and 10 deletions.
  1. +19 −5 build.ps1
  2. +26 −5 build.psake.ps1
View
@@ -21,7 +21,7 @@
The build task that needs to be executed. The value of this parameter can be:
- Build
- - Release
+ - PrepareRelease
- Analyze
- UpdateModuleManifest
- UpdateDocumentation
@@ -35,6 +35,16 @@
The BumpVersion will increment the version of the Module Manifest based on the $BumpVersion setting provided in build.settings.ps1.
By default this is patch.
+ .PARAMETER Version
+ The part of the version you wish to bump for this release.
+
+ Possible values are:
+
+ - NONE
+ - PATCH
+ - MINOR
+ - MAJOR
+
.INPUTS
System.String
@@ -45,7 +55,7 @@
.\build.ps1
.Example
- .\build.ps1 -Task Release
+ .\build.ps1 -Task PrepareRelease
.Example
.\build.ps1 -Task Analyze
@@ -69,12 +79,16 @@
Param (
[Parameter()]
- [ValidateSet("Build", "Release", "Analyze", "UpdateModuleManifest", "UpdateDocumentation", "BumpVersion", "Test")]
- [String]$Task = "Build"
+ [ValidateSet("Build", "PrepareRelease", "Analyze", "UpdateModuleManifest", "UpdateDocumentation", "BumpVersion", "Test")]
+ [String]$Task = "Build",
+
+ [Parameter()]
+ [ValidateSet("PATCH", "MINOR", "MAJOR")]
+ [String]$Version
)
# --- Start Build
-Invoke-psake -buildFile "$($PSScriptRoot)\build.psake.ps1" -taskList $Task -nologo -Verbose:$VerbosePreference
+Invoke-psake -buildFile "$($PSScriptRoot)\build.psake.ps1" -taskList $Task -parameters @{"Version"=$Version} -nologo -Verbose:$VerbosePreference
exit ( [int]( -not $psake.build_success ) )
View
@@ -1,10 +1,17 @@
# --- Dot source build.settings.ps1
. $PSScriptRoot\build.settings.ps1
+# --- Add any parameters from build.ps1
+properties {
+
+ $BumpVersion = $Version
+
+}
+
# --- Define the build tasks
Task Default -depends Build
Task Build -depends Analyze, UpdateModuleManifest, UpdateDocumentation
-Task Release -depends Build, Test, BumpVersion
+Task PrepareRelease -depends Build, BumpVersion
Task Analyze {
@@ -203,7 +210,7 @@ Task BumpVersion {
switch ($BumpVersion) {
- 'Major' {
+ 'MAJOR' {
Write-Verbose -Message "Bumping module major release number"
@@ -215,7 +222,7 @@ Task BumpVersion {
}
- 'Minor' {
+ 'MINOR' {
Write-Verbose -Message "Bumping module minor release number"
@@ -226,7 +233,7 @@ Task BumpVersion {
}
- 'Patch' {
+ 'PATCH' {
Write-Verbose -Message "Bumping module patch release number"
@@ -235,17 +242,31 @@ Task BumpVersion {
break
}
+ default {
+
+ Write-Verbose -Message "Not bumping module version"
+ break
+
+ }
+
}
# --- Build the new version string
$ModuleVersion = "$($MajorVersion).$($MinorVersion).$($PatchVersion)"
- if ($ModuleVersion -gt $CurrentModuleVersion) {
+ if ([version]$ModuleVersion -gt [version]$CurrentModuleVersion) {
# --- Fix taken from: https://github.com/RamblingCookieMonster/BuildHelpers/blob/master/BuildHelpers/Public/Step-ModuleVersion.ps1
New-ModuleManifest -Path $ModuleManifestPath -ModuleVersion $ModuleVersion @ModuleManifest -Verbose:$VerbosePreference
Write-Verbose -Message "Module version updated to $($ModuleVersion)"
+ # --- Update appveyor build version
+ $AppveyorYMLPath = "$($PSScriptRoot)\appveyor.yml"
+ $AppveyorVersion = "$($ModuleVersion).{build}"
+ $NewAppveyorYML = Get-Content -Path $AppveyorYMLPath | ForEach-Object { $_ -replace '^version: .+$', "version: $($AppveyorVersion)";}
+ $NewAppveyorYML | Set-Content -Path $AppveyorYMLPath -Force
+ Write-Verbose -Message "Appveyor build version set to $($AppveyorVersion)"
+
}
}

0 comments on commit e051c00

Please sign in to comment.