fix(release): preserve unreleased changelog entries (#55)

(cherry picked from commit e7989c1bb03ec461c638de89337d175f8ef115e4)
This commit is contained in:
修雨
2026-07-13 15:34:28 +08:00
committed by 修雨
parent e3cedc8f67
commit 82bb8f3026
2 changed files with 56 additions and 5 deletions
+20 -5
View File
@@ -79,14 +79,29 @@ trap cleanup EXIT HUP INT TERM
} > "$section"
inserted=0
in_unreleased=0
while IFS= read -r line || [ -n "$line" ]; do
case "$line" in
'## [Unreleased]')
in_unreleased=1
;;
'## '*)
if [ "$in_unreleased" -eq 1 ]; then
cat "$section" >> "$output"
printf '\n' >> "$output"
inserted=1
in_unreleased=0
fi
;;
esac
printf '%s\n' "$line" >> "$output"
if [ "$line" = '## [Unreleased]' ]; then
printf '\n' >> "$output"
cat "$section" >> "$output"
inserted=1
fi
done < "$CHANGELOG"
if [ "$in_unreleased" -eq 1 ]; then
printf '\n' >> "$output"
cat "$section" >> "$output"
inserted=1
fi
[ "$inserted" -eq 1 ] || { printf 'CHANGELOG is missing ## [Unreleased]\n' >&2; exit 1; }
cp "$output" "$CHANGELOG"