|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +RELEASE_VERSION="$1" |
| 4 | + |
| 5 | +# Delete until the first line containing "--" |
| 6 | +sed -i '1,/--/d' temp_change.md |
| 7 | +# Reverse the order of lines in the file (last line becomes first, etc.) |
| 8 | +sed -i '1h;1d;$!H;$!d;G' temp_change.md |
| 9 | +# Convert "**Full Changelog**: URL" format to markdown link format "[Full Changelog](URL)" |
| 10 | +sed -i -re 's/\*\*Full Changelog\*\*: (.*)/\[Full Changelog\]\(\1\)\n/' temp_change.md |
| 11 | +# Delete everything from "## New Contributors" line to the end of file |
| 12 | +sed -i '/## New Contributors/,$d' temp_change.md |
| 13 | +# Convert GitHub changelog entries from "* description by @username in pull/URL/number" |
| 14 | +# to "- description [#number](pull/URL/number) ([username](https://github.com/username))" format |
| 15 | +sed -i -re 's/^\*(.*)\sby\s@(.*)\sin\s(.*\/pull\/)(.*)/-\1 [\\#\4](\3\4) ([\2](https:\/\/github.com\/\2))/' temp_change.md |
| 16 | +# Username substitutions for preferred display names |
| 17 | +sed -i 's/\[Quotae/\[Quote_a/' temp_change.md |
| 18 | +sed -i 's/\[learn2draw/\[Lexy/' temp_change.md |
| 19 | +sed -i 's/\[Voronoff/\[Tom Clancy Is Dead/' temp_change.md |
| 20 | +sed -i 's/\[PJacek/\[TPlant/' temp_change.md |
| 21 | +sed -i 's/\[justjuangui/\[trompetin17/' temp_change.md |
| 22 | + |
| 23 | +cp temp_change.md changelog_temp.txt |
| 24 | +# Append existing CHANGELOG.md content (excluding first line) to temp_change.md |
| 25 | +sed '1d' CHANGELOG.md >> temp_change.md |
| 26 | +# Create new CHANGELOG.md with header containing version and date, followed by processed changes |
| 27 | +printf "# Changelog\n\n## [$RELEASE_VERSION](https://github.com/PathOfBuildingCommunity/PathOfBuilding-PoE2/tree/$RELEASE_VERSION) ($(date +'%Y/%m/%d'))\n\n" | cat - temp_change.md > CHANGELOG.md |
| 28 | +# Convert changelog entries from markdown link format to simplified "* description (username)" format |
| 29 | +sed -i -re 's/^- (.*) \[.*\) \(\[(.*)\]\(.*/* \1 (\2)/' changelog_temp.txt |
| 30 | +# Create new changelog format: add version header, remove lines 2-3, format section headers, remove ## headers with following line, prepend to existing changelog |
| 31 | +echo "VERSION[${RELEASE_VERSION#v}][$(date +'%Y/%m/%d')]" | cat - changelog_temp.txt | sed '2,3d' | sed -re 's/^### (.*)/\n--- \1 ---/' | sed -e '/^##.*/,+1 d' | cat - changelog.txt > changelog_new.txt |
| 32 | +mv changelog_new.txt changelog.txt |
| 33 | + |
| 34 | +# Normalize line endings to CRLF for all output files to ensure consistent checksums with Windows |
| 35 | +sed 's/\r*$/\r/' CHANGELOG.md > CHANGELOG_normalized.md && mv CHANGELOG_normalized.md CHANGELOG.md |
| 36 | +sed 's/\r*$/\r/' changelog.txt > changelog_normalized.txt && mv changelog_normalized.txt changelog.txt |
| 37 | + |
| 38 | +# Clean up temporary files |
| 39 | +rm temp_change.md |
| 40 | +rm changelog_temp.txt |
0 commit comments