@@ -3,6 +3,21 @@ Function Get-SolutionPath
3
3
Split-Path $PSScriptRoot - Parent
4
4
}
5
5
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
+
6
21
Function New-Release
7
22
{
8
23
[CmdletBinding ()]
@@ -15,15 +30,9 @@ Function New-Release
15
30
$isVersionGiven = $false
16
31
}
17
32
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
27
36
if ($versions.Count -le 2 )
28
37
{
29
38
throw " This edge condition for the number versions less that 2 is not implemented."
@@ -61,6 +70,39 @@ Function New-Release
61
70
# update version
62
71
Update-Version $newVer $oldVer $solutionRoot
63
72
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 )
64
106
$changelogRegexPattern = " ##\s\[{0}\].*\n((?:.*\n)+)##\s\[{1}\].*" `
65
107
-f [regex ]::Escape($newVer ), [regex ]::Escape($oldVer )
66
108
$changelogRegex = [regex ]::new($changelogRegexPattern )
@@ -80,17 +122,6 @@ Function New-Release
80
122
$r = [regex ]::new($releaseNotesPattern )
81
123
$updatedManifestContent = $r.Replace ([System.IO.File ]::ReadAllText($moduleManifestPath ), $replacement )
82
124
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
-
94
125
}
95
126
96
127
function Combine-Path
0 commit comments