2023-03-24 22:29:15 +03:00
|
|
|
param (
|
|
|
|
[string]
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
$version,
|
2023-07-14 20:07:17 +03:00
|
|
|
[switch]
|
|
|
|
[bool]
|
2023-09-18 22:32:44 +03:00
|
|
|
$createNotes
|
2023-03-24 22:29:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
$version = $version.TrimStart("v")
|
|
|
|
|
2023-08-23 22:33:14 +03:00
|
|
|
$changelogPath = Join-Path -Path $PSScriptRoot -ChildPath "../CHANGELOG.md"
|
2023-07-14 20:07:17 +03:00
|
|
|
|
|
|
|
$changeLogContent = Get-Content $changelogPath -Raw
|
2023-03-24 22:29:15 +03:00
|
|
|
$headerLine = "## [$version]"
|
2023-07-14 20:07:17 +03:00
|
|
|
$versionLineNumber = $changeLogContent.IndexOf($headerLine)
|
|
|
|
if ($version -ne "Unreleased" -and $versionLineNumber -lt 0) {
|
|
|
|
throw "Version $version not found in CHANGELOG.md make sure you've updated the changelog"
|
|
|
|
}
|
2024-08-07 16:11:06 +03:00
|
|
|
$headerLineNumber = $changeLogContent.IndexOf("`n" , $versionLineNumber) + 3
|
2023-03-24 22:29:15 +03:00
|
|
|
$endLineNumber = $changeLogContent.IndexOf("## [", $headerLineNumber) - 3
|
|
|
|
$releaseNotes = $changeLogContent.Substring($headerLineNumber, $endLineNumber - $headerLineNumber)
|
2023-07-14 20:07:17 +03:00
|
|
|
if ($version -eq "Unreleased" -and [string]::IsNullOrWhiteSpace($releaseNotes.Replace("### Changed", "").Replace("### Added", ""))) {
|
|
|
|
throw "Version $version not found in CHANGELOG.md make sure you've updated the changelog"
|
|
|
|
}
|
2023-09-18 22:32:44 +03:00
|
|
|
if ($createNotes -eq $true) {
|
2023-07-14 20:09:26 +03:00
|
|
|
$targetFile = Join-Path (Split-Path $changelogPath -Parent) "release-notes.txt"
|
2023-07-14 20:07:17 +03:00
|
|
|
Set-Content -Path $targetFile -Value $releaseNotes -Verbose
|
|
|
|
}
|