handles versioning when module is notpublished resolves #5

This commit is contained in:
Kevin Marquette
2018-08-21 14:20:08 -07:00
parent 6688e9b438
commit 45b674cf3d

View File

@@ -25,8 +25,9 @@ function GetModulePublicInterfaceMap
} }
task SetVersion { task SetVersion {
$version = $null $version = [version]"0.1.0"
$publishedModule = $null
$bumpVersionType = 'Patch'
$versionStamp = (git rev-parse origin/master) + (git rev-parse head) $versionStamp = (git rev-parse origin/master) + (git rev-parse head)
"Load current version" "Load current version"
@@ -51,25 +52,28 @@ task SetVersion {
Sort-Object -Property {[version]$_.Version} -Descending | Sort-Object -Property {[version]$_.Version} -Descending |
Select -First 1 Select -First 1
[version] $publishedVersion = $publishedModule.Version if($null -ne $publishedModule)
" Published version [$publishedVersion]"
$version = $publishedVersion
"Downloading published module to check for breaking changes"
$publishedModule | Save-Module -Path $downloadFolder
[System.Collections.Generic.HashSet[string]] $publishedInterface = GetModulePublicInterfaceMap -Path (Join-Path $downloadFolder $ModuleName)
[System.Collections.Generic.HashSet[string]] $buildInterface = GetModulePublicInterfaceMap -Path $ManifestPath
$bumpVersionType = 'Patch'
if( -not $publishedInterface.IsSubsetOf($buildInterface))
{ {
$bumpVersionType = 'Major' [version] $publishedVersion = $publishedModule.Version
} " Published version [$publishedVersion]"
elseif ($publishedInterface.count -ne $buildInterface.count)
{ $version = $publishedVersion
$bumpVersionType = 'Minor'
"Downloading published module to check for breaking changes"
$publishedModule | Save-Module -Path $downloadFolder
[System.Collections.Generic.HashSet[string]] $publishedInterface = GetModulePublicInterfaceMap -Path (Join-Path $downloadFolder $ModuleName)
[System.Collections.Generic.HashSet[string]] $buildInterface = GetModulePublicInterfaceMap -Path $ManifestPath
if( -not $publishedInterface.IsSubsetOf($buildInterface))
{
$bumpVersionType = 'Major'
}
elseif ($publishedInterface.count -ne $buildInterface.count)
{
$bumpVersionType = 'Minor'
}
} }
if ($version -lt ([version] '1.0.0')) if ($version -lt ([version] '1.0.0'))
@@ -109,7 +113,7 @@ task SetVersion {
Update-Metadata -Path $ManifestPath -PropertyName 'ModuleVersion' -Value $version Update-Metadata -Path $ManifestPath -PropertyName 'ModuleVersion' -Value $version
(Get-Content -Path $ManifestPath -Raw -Encoding UTF8) | (Get-Content -Path $ManifestPath -Raw -Encoding UTF8) |
% trimend | ForEach-Object {$_.TrimEnd()} |
Set-Content -Path $ManifestPath -Encoding UTF8 Set-Content -Path $ManifestPath -Encoding UTF8
Set-Content -Path $versionFile -Value $versionStamp -NoNewline -Encoding UTF8 Set-Content -Path $versionFile -Value $versionStamp -NoNewline -Encoding UTF8