@@ -3,6 +3,21 @@ Function Get-SolutionPath
33 Split-Path $PSScriptRoot - Parent
44}
55
6+ Function Get-ChangeLogPath
7+ {
8+ Join-Path (Get-SolutionPath ) ' CHANGELOG.MD'
9+ }
10+
11+ Function Get-EngineProjectPath
12+ {
13+ Join-Path (Get-SolutionPath ) ' Engine'
14+ }
15+
16+ Function Get-ModuleManifestPath
17+ {
18+ Join-Path (Get-EngineProjectPath ) ' PSScriptAnalyzer.psd1'
19+ }
20+
621Function New-Release
722{
823 [CmdletBinding ()]
@@ -15,15 +30,9 @@ Function New-Release
1530 $isVersionGiven = $false
1631 }
1732
18- $solutionRoot = (Get-SolutionPath )
19-
20- $enginePath = Join-Path $solutionRoot " Engine"
21-
22- # Check if the changelog has entry for $newVer
23- $moduleManifestPath = Join-Path $enginePath " PSScriptAnalyzer.psd1"
24- $changelogPath = Join-Path $solutionRoot ' CHANGELOG.MD'
25- $matches = [regex ]::new(" \[(\d+\.\d+\.\d+)\]" ).Matches((get-content $changelogPath - raw))
26- $versions = $matches | ForEach-Object {$_.Groups [1 ].Value}
33+ $solutionRoot = Get-SolutionPath
34+ $enginePath = Get-EngineProjectPath
35+ $versions = Get-VersionsFromChangeLog
2736 if ($versions.Count -le 2 )
2837 {
2938 throw " This edge condition for the number versions less that 2 is not implemented."
@@ -61,6 +70,39 @@ Function New-Release
6170 # update version
6271 Update-Version $newVer $oldVer $solutionRoot
6372
73+ # copy release notes from changelog to module manifest
74+ Update-ReleaseNotesInModuleManifest $newVer $oldVer
75+
76+ # build the module
77+ pushd $solutionRoot
78+ remove-item out/ - recurse - force
79+ dotnet restore
80+ .\buildCoreClr.ps1 - Framework net451 - Configuration Release - Build
81+ .\buildCoreClr.ps1 - Framework net451 - Configuration PSV3Release - Build
82+ .\buildCoreClr.ps1 - Framework netstandard1.6 - Configuration Release - Build
83+ .\build.ps1 - BuildDocs
84+ popd
85+
86+ }
87+
88+ function Get-VersionsFromChangeLog
89+ {
90+ $moduleManifestPath = Get-ModuleManifestPath
91+ $changelogPath = Get-ChangeLogPath
92+ $matches = [regex ]::new(" \[(\d+\.\d+\.\d+)\]" ).Matches((get-content $changelogPath - raw))
93+ $versions = $matches | ForEach-Object {$_.Groups [1 ].Value}
94+ $versions
95+ }
96+
97+ function Update-ReleaseNotesInModuleManifest
98+ {
99+ [CmdletBinding ()]
100+ param ($newVer , $oldVer )
101+
102+ $moduleManifestPath = Get-ModuleManifestPath
103+ Write-Verbose (" Module manifest: {0}" -f $moduleManifestPath )
104+ $changelogPath = Get-ChangeLogPath
105+ Write-Verbose (" CHANGELOG: {0}" -f $changelogPath )
64106 $changelogRegexPattern = " ##\s\[{0}\].*\n((?:.*\n)+)##\s\[{1}\].*" `
65107 -f [regex ]::Escape($newVer ), [regex ]::Escape($oldVer )
66108 $changelogRegex = [regex ]::new($changelogRegexPattern )
@@ -80,17 +122,6 @@ Function New-Release
80122 $r = [regex ]::new($releaseNotesPattern )
81123 $updatedManifestContent = $r.Replace ([System.IO.File ]::ReadAllText($moduleManifestPath ), $replacement )
82124 Set-ContentUtf8NoBom $moduleManifestPath $updatedManifestContent
83-
84- # build the module
85- pushd $solutionRoot
86- remove-item out/ - recurse - force
87- dotnet restore
88- .\buildCoreClr.ps1 - Framework net451 - Configuration Release - Build
89- .\buildCoreClr.ps1 - Framework net451 - Configuration PSV3Release - Build
90- .\buildCoreClr.ps1 - Framework netstandard1.6 - Configuration Release - Build
91- .\build.ps1 - BuildDocs
92- popd
93-
94125}
95126
96127function Combine-Path
0 commit comments