From 00e2e9795804d64aae90113e87e36c82ad99b9c8 Mon Sep 17 00:00:00 2001 From: NateScarlet Date: Thu, 25 Mar 2021 13:53:02 +0800 Subject: [PATCH] ci: fix auto relase description --- appveyor.yml | 6 ++++++ scripts/get_changelog.ps1 | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 scripts/get_changelog.ps1 diff --git a/appveyor.yml b/appveyor.yml index 4d3d0986..135218b1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,9 +6,15 @@ build_script: - make build after_build: - 7z a -tzip -xr!.* -xr0!build build\\WuLiFang-Nuke-%APPVEYOR_REPO_TAG_NAME%-win.zip + - ps: | + ${env:APPVEYOR_RELEASE_DESCRIPTION} = ./scripts/get_changelog.ps1 -Version v2021.0.1 + Write-Host ${env:APPVEYOR_RELEASE_DESCRIPTION} artifacts: - path: build\WuLiFang-Nuke-*.zip name: Built package +before_deploy: + - ps: | + ${env:APPVEYOR_RELEASE_DESCRIPTION} = ./scripts/get_changelog.ps1 -Version $env:APPVEYOR_REPO_TAG_NAME deploy: tag: $(APPVEYOR_REPO_TAG_NAME) release: $(APPVEYOR_REPO_TAG_NAME) diff --git a/scripts/get_changelog.ps1 b/scripts/get_changelog.ps1 new file mode 100644 index 00000000..037e4c6b --- /dev/null +++ b/scripts/get_changelog.ps1 @@ -0,0 +1,30 @@ +param ( + [Parameter()] + [String] + $Version +) + +$ret = @() +$isMatch = $false +foreach ($line in Get-Content -Encoding utf8 docs/changelog.md) { + if ($line -match "## \[(?.+)]") { + if ($Matches.version -eq ($Version -replace "^v", "")) { + $isMatch = $true + } + elseif ($isMatch) { + break + } + continue + } + + if ($isMatch) { + $ret += $line + } +} + +if ($ret.Length -eq 0) { + throw "Version not found: $Version" +} + + +return $ret -join "`n"