diff --git a/PSReadLine.build.ps1 b/PSReadLine.build.ps1 index 66809e3b..8f5db1fb 100644 --- a/PSReadLine.build.ps1 +++ b/PSReadLine.build.ps1 @@ -191,7 +191,23 @@ task LayoutModule BuildMainModule, BuildMamlHelp, { # Copy module manifest, but fix the version to match what we've specified in the binary module. $version = (Get-ChildItem -Path $targetDir/Microsoft.PowerShell.PSReadLine2.dll).VersionInfo.FileVersion $moduleManifestContent = Get-Content -Path 'PSReadLine/PSReadLine.psd1' -Raw - [regex]::Replace($moduleManifestContent, "ModuleVersion = '.*'", "ModuleVersion = '$version'") | Set-Content -Path $targetDir/PSReadLine.psd1 + + $b = Get-Content -Encoding Byte -Raw ./bin/$Configuration/PSReadLine/Microsoft.PowerShell.PSReadLine2.dll + $a = [System.Reflection.Assembly]::Load($b) + $semVer = ($a.GetCustomAttributes([System.Reflection.AssemblyInformationalVersionAttribute], $false)).InformationalVersion + + if ($semVer -match "(.*)-(.*)") + { + # Make sure versions match + if ($matches[1] -ne $version) { throw "AssemblyFileVersion mismatch with AssemblyInformationalVersion" } + $prerelease = $matches[2] + + # Put the prerelease tag in private data + $moduleManifestContent = [regex]::Replace($moduleManifestContent, "}", "PrivateData = @{ PSData = @{ Prerelease = '$prerelease' } }$([System.Environment]::Newline)}") + } + + $moduleManifestContent = [regex]::Replace($moduleManifestContent, "ModuleVersion = '.*'", "ModuleVersion = '$version'") + $moduleManifestContent | Set-Content -Path $targetDir/PSReadLine.psd1 # Make sure we don't ship any read-only files foreach ($file in (Get-ChildItem -Recurse -File $targetDir)) @@ -238,6 +254,44 @@ task Install LayoutModule, { Install "$HOME\Documents\PowerShell\Modules" } +<# +Synopsis: Publish to PSGallery +#> +task Publish -If ($Configuration -eq 'Release') LayoutModule, { + + $manifest = Import-PowerShellDataFile $PSScriptRoot/bin/Release/PSReadLine/PSReadLine.psd1 + + $version = $manifest.ModuleVersion + if ($null -ne $manifest.PrivateData) + { + $psdata = $manifest.PrivateData['PSData'] + if ($null -ne $psdata) + { + $prerelease = $psdata['Prerelease'] + if ($null -ne $prerelease) + { + $version = $version + '-' + $prerelease + } + } + } + + $yes = Read-Host "Publish version $version (y/n)" + + if ($yes -ne 'y') { throw "Publish aborted" } + + $nugetApiKey = Read-Host "Nuget api key for PSGallery" + + $publishParams = @{ + Path = "$PSScriptRoot/bin/Release/PSReadLine" + NuGetApiKey = $nugetApiKey + Repository = "PSGallery" + ReleaseNotes = (Get-Content -Raw $PSScriptRoot/bin/Release/PSReadLine/Changes.txt) + ProjectUri = 'https://github.com/lzybkr/PSReadLine' + } + + Publish-Module @publishParams +} + <# Synopsis: Default build rule - build and create module layout #> diff --git a/PSReadLine/AssemblyInfo.cs b/PSReadLine/AssemblyInfo.cs index f7663f2a..f6c05ba4 100644 --- a/PSReadLine/AssemblyInfo.cs +++ b/PSReadLine/AssemblyInfo.cs @@ -10,7 +10,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("PSReadLine")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyDescription("Great command line editing in PowerShell")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PSReadLine")] @@ -37,7 +37,8 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("2.0.0.0")] -[assembly: AssemblyFileVersion("2.0")] +[assembly: AssemblyFileVersion("2.0.0")] +[assembly: AssemblyInformationalVersion("2.0.0-beta1")] [assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed")]