1+ Param (
2+ [Parameter (Mandatory = $true )]
3+ [ValidateNotNullOrEmpty ()]
4+ [string ]$OldVersion ,
5+ [Parameter (Mandatory = $true )]
6+ [ValidateNotNullOrEmpty ()]
7+ [string ]$NewVersion
8+ )
9+
10+ Set-StrictMode - Version Latest
11+ $ErrorActionPreference = ' Stop'
12+
13+ function Update-XmlVersion ([System.IO.FileInfo ]$XmlFile , [string ]$Version , [string ]$NodePath )
14+ {
15+ [Xml ]$XmlContent = Get-Content $XmlFile
16+ $Node = $XmlContent.SelectSingleNode ($NodePath )
17+ $Node.InnerText = $Version
18+ " $ ( $Node.OuterXml ) "
19+ $XmlContent.Save ($XmlFile )
20+ }
21+
22+ function Update-JsonVersion ([System.IO.FileInfo ]$JsonFile , [string ]$Version )
23+ {
24+ $JsonContent = Get-Content $JsonFile | ConvertFrom-Json
25+ $JsonContent.version = $Version
26+ " $ ( $JsonFile ) : $ ( $JsonContent.version ) "
27+ $JsonContent | ConvertTo-Json | Out-File $JsonFile
28+ }
29+
30+ function Update-TextVersion ([System.IO.FileInfo ]$TextFile , [string ]$OldVersion , [string ]$NewVersion )
31+ {
32+ $OldContent = Get-Content $TextFile | Out-String
33+ $NewContent = $OldContent.Replace ($OldVersion , $NewVersion )
34+ " $ ( $TextFile ) : $NewVersion "
35+ $NewContent | Out-File $TextFile
36+ }
37+
38+ function Update-ReleaseNotes ([System.IO.FileInfo ]$XmlFile , [string ]$Content , [string ]$Version )
39+ {
40+ [Xml ]$XmlContent = Get-Content $XmlFile
41+ $NewChild = New-Object System.Xml.XmlDocument
42+ $NewChild.LoadXml ($Content.Replace (' %Version%' , $Version ))
43+ $Node = $XmlContent.SelectSingleNode (' /document/body/section' )
44+ $Node.PrependChild ($XmlContent.ImportNode ($NewChild.DocumentElement , $true ))
45+ " $ ( $XmlFile ) : $NewVersion "
46+ $XmlContent.Save ($XmlFile )
47+ }
48+
49+ Update-XmlVersion $PSScriptRoot / ../ pom.xml $NewVersion ' /*[local-name()="project"]/*[local-name()="version"]'
50+ Update-JsonVersion $PSScriptRoot / ../ package.json $NewVersion
51+ Update-TextVersion $PSScriptRoot / ../ doc/ MailTemplate.txt $OldVersion $NewVersion
52+ Update-TextVersion $PSScriptRoot / ../ doc/ MailTemplate.Result.txt $OldVersion $NewVersion
53+ Update-TextVersion $PSScriptRoot / ../ doc/ MailTemplate.Announce.txt $OldVersion $NewVersion
54+ Update-XmlVersion $PSScriptRoot / ../ src/ log4net/ log4net.csproj $NewVersion ' /Project/PropertyGroup/Version'
55+
56+ $ReleaseNoteSection = '
57+ <section id="a%Version%" name="%Version%">
58+ <section id="a%Version%-breaking" name="Breaking Changes">
59+ </section>
60+ <br/>
61+ Apache log4net %Version% addresses reported issues:
62+ <section id="a%Version%-bug" name="Bug fixes">
63+ <ul>
64+ <li>
65+ <a href="https://github.com/apache/logging-log4net/issues/tbd">tbd</a> (by tbd)
66+ </li>
67+ </ul>
68+ </section>
69+ <section id="a%Version%-enhancements" name="Enhancements">
70+ <ul>
71+ <li>
72+ <a href="https://github.com/apache/logging-log4net/issues/tbd">tbd</a> (by tbd)
73+ </li>
74+ </ul>
75+ </section>
76+ </section>'
77+
78+ Update-ReleaseNotes $PSScriptRoot / ../ src/ site/ xdoc/ release/ release- notes.xml $ReleaseNoteSection $NewVersion
0 commit comments