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,6 +52,8 @@ task SetVersion {
Sort-Object -Property {[version]$_.Version} -Descending | Sort-Object -Property {[version]$_.Version} -Descending |
Select -First 1 Select -First 1
if($null -ne $publishedModule)
{
[version] $publishedVersion = $publishedModule.Version [version] $publishedVersion = $publishedModule.Version
" Published version [$publishedVersion]" " Published version [$publishedVersion]"
@@ -62,7 +65,7 @@ task SetVersion {
[System.Collections.Generic.HashSet[string]] $publishedInterface = GetModulePublicInterfaceMap -Path (Join-Path $downloadFolder $ModuleName) [System.Collections.Generic.HashSet[string]] $publishedInterface = GetModulePublicInterfaceMap -Path (Join-Path $downloadFolder $ModuleName)
[System.Collections.Generic.HashSet[string]] $buildInterface = GetModulePublicInterfaceMap -Path $ManifestPath [System.Collections.Generic.HashSet[string]] $buildInterface = GetModulePublicInterfaceMap -Path $ManifestPath
$bumpVersionType = 'Patch'
if( -not $publishedInterface.IsSubsetOf($buildInterface)) if( -not $publishedInterface.IsSubsetOf($buildInterface))
{ {
$bumpVersionType = 'Major' $bumpVersionType = 'Major'
@@ -71,6 +74,7 @@ task SetVersion {
{ {
$bumpVersionType = 'Minor' $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