-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmkchangelog.ps1
More file actions
41 lines (38 loc) · 2.08 KB
/
mkchangelog.ps1
File metadata and controls
41 lines (38 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$useLegacy = ($PSVersionTable.PSVersion -as [version]) -le ("2.0" -as [version])
if ($useLegacy){
$inputDir = Split-Path -Parent $MyInvocation.MyCommand.Path
}
else {
$inputDir = $PSScriptRoot
}
$theRootestRoot = Split-Path -Parent $inputDir;
$outputDir = Join-Path -Path $theRootestRoot -ChildPath \_Build\ProductInfo
$changeLogFile = Join-Path -Path $outputDir -ChildPath "ChangeLog.txt"
$releaseNotesFile = Join-Path -Path $outputDir -ChildPath "ReleaseNotes.txt"
if (-not (Test-Path $outputDir)) { New-Item $outputDir -Type directory -Force }
if (Test-Path $changeLogFile) { Remove-Item $changeLogFile -Force }
if (Test-Path $releaseNotesFile) { Remove-Item $releaseNotesFile -Force }
#perform right files order
$items = Get-ChildItem -Path $inputDir -Filter *.txt |
Select-Object -Property @{Name = "FileName"; Expression = {$_.BaseName}},
@{Name = "File"; Expression = {$_}},
@{Name = "ReleaseVersion"; Expression= {($_.BaseName -split "_", 2)[0] -as [Version]}},
@{Name ="ReleaseName"; Expression= {($_.BaseName -split "_", 2)[1] }},
@{Name ="FixedReleaseName"; Expression = {($_.BaseName -split "_", 2)[1] -replace "Z_Final", "Final"}} |
Sort-Object -Property @{Expression="ReleaseVersion";Descending=$true}, @{Expression="ReleaseName";Descending=$true}
#compose ChangeLog and ReleaseInfo files
Foreach ($complexObject in $items) {
$isInitial = $complexObject.FileName -eq "0.0.0"
if($isInitial){
Add-Content $changeLogFile ( Get-Content $complexObject.File.FullName)
Add-Content $changeLogFile ""
}
else{
#on first itteration create ReleaseNotes
if (-not(Test-Path $releaseNotesFile)) { Add-Content $releaseNotesFile (Get-Content $complexObject.File.FullName) }
Add-Content $changeLogFile ("Changes in {0} {1}" -f $complexObject.ReleaseVersion, $complexObject.FixedReleaseName)
Add-Content $changeLogFile ""
Add-Content $changeLogFile ( Get-Content $complexObject.File.FullName)
Add-Content $changeLogFile ""
}
}