Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions .github/tweak_changelogs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,56 @@ RELEASE_VERSION="$1"

# Delete until and including the first line containing "<!-- Release notes generated"
sed -i '1,/^<!-- Release notes generated/d' temp_change.md

# Check if there is more than one non-empty line (the full changelog line) before we continue
if [ $(grep -c '^[[:space:]]*[^[:space:]]' temp_change.md) -le 1 ]; then
echo "No changes to release $RELEASE_VERSION"
rm temp_change.md
exit 1
fi

# Remove all CR characters from all changelog files
sed -i 's/\r//g' temp_change.md CHANGELOG.md changelog.txt

# Reverse the order of lines in the file (last line becomes first, etc.)
sed -i '1h;1d;$!H;$!d;G' temp_change.md
# Convert "**Full Changelog**: URL" format to markdown link format "[Full Changelog](URL)"
sed -i -re 's/\*\*Full Changelog\*\*: (.*)/\[Full Changelog\]\(\1\)\n/' temp_change.md
# Delete everything from "## New Contributors" line to the end of file
sed -i '/## New Contributors/,$d' temp_change.md
# Convert GitHub changelog entries from "* description by @username in pull/URL/number"
# to "- description [#number](pull/URL/number) ([username](https://github.com/username))" format
sed -i -re 's/^\*(.*)\sby\s@(.*)\sin\s(.*\/pull\/)(.*)\r?/-\1 [\\#\4](\3\4) ([\2](https:\/\/github.com\/\2))/' temp_change.md;
# Convert GitHub changelog entries to markdown format
# "* description by (@username1, @username2) in #1310, #1311" → "- description #1310, #1311 (@username1, @username2)"
sed -i -re 's/^\*\s(.*)\sby\s\(?(@[^)]*[^) ])\)?\s+in\s+(.*)/- \1 \3 (\2)/' temp_change.md
# Convert @usernames to github links
# "(@username1, @username2)" → "([username1](https://github.com/username1), [username2](https://github.com/username2))"
sed -i -re 's/@([a-zA-Z0-9_-]+)/[\1](https:\/\/github.com\/\1)/g' temp_change.md
# Convert full PR URLs to linked format
# "https://github.com/repo/pull/1310" → "[\#1310](https://github.com/repo/pull/1310)"
sed -i -re 's/(https:\/\/[^) ]*\/pull\/([0-9]+))/[\\#\2](\1)/g' temp_change.md

# Username substitutions for preferred display names
sed -i 's/\[Quotae/\[Quote_a/' temp_change.md
sed -i 's/\[learn2draw/\[Lexy/' temp_change.md
sed -i 's/\[Voronoff/\[Tom Clancy Is Dead/' temp_change.md
sed -i 's/\[PJacek/\[TPlant/' temp_change.md
sed -i 's/\[justjuangui/\[trompetin17/' temp_change.md

sed -i 's/\r//g' temp_change.md

cp temp_change.md changelog_temp.txt
# Append existing CHANGELOG.md content (excluding first line) to temp_change.md
cat CHANGELOG.md | tr \\r \\n | sed '1d' >> temp_change.md
cat CHANGELOG.md | sed '1d' >> temp_change.md
# Create new CHANGELOG.md with header containing version and date, followed by processed changes
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
# Convert changelog entries from markdown link format to simplified "* description (username)" format
sed -i -re 's/^- (.*) \[.*\) \(\[(.*)\]\(.*/* \1 (\2)/' changelog_temp.txt
# First remove all PR links
sed -i -re 's/( \()?\[\\#[0-9]+\]\([^)]*\),? ?\)?//g' changelog_temp.txt
# Remove markdown link formatting from usernames in parentheses
sed -i -re 's/\[([^]]*)\]\(https:\/\/github\.com\/[^)]*\)/\1/g' changelog_temp.txt
# Create new changelog format: add version header, remove lines 2-3, format section headers, remove ## headers with following line, prepend to existing changelog
echo "VERSION[${RELEASE_VERSION#v}][$(date +'%Y/%m/%d')]" | cat - changelog_temp.txt | tr -d \\r | sed '2,3d' | sed -re 's/^### (.*)/\n--- \1 ---/' | sed -e '/^##.*/,+1 d' | cat - changelog.txt > changelog_new.txt
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
mv changelog_new.txt changelog.txt

# Normalize line endings to CRLF for all output files to ensure consistent checksums with Windows
sed 's/\r*$/\r/' CHANGELOG.md > CHANGELOG_normalized.md && mv CHANGELOG_normalized.md CHANGELOG.md
sed 's/\r*$/\r/' changelog.txt > changelog_normalized.txt && mv changelog_normalized.txt changelog.txt
sed -i 's/\r*$/\r/' CHANGELOG.md changelog.txt

# Clean up temporary files
rm temp_change.md
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ jobs:
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# The hash suffix will help identifying if the beta version is up-to-date
- name: Add commit hash suffix to manifest version
run: |
sed -i "s/<Version number=\"\([^\"]*\)\"/<Version number=\"\1-$(git rev-parse --short HEAD)\"/g" manifest.xml
- name: Generate Release notes
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
Expand All @@ -35,11 +31,18 @@ jobs:
gh release create beta --title "Beta Release" --draft --generate-notes
gh release view beta > temp_change.md
- name: Tweak changelogs
id: tweak-changelogs
continue-on-error: true
run: |
# Remove carriage returns to be able to run the script
sed -i 's/\r$//' .github/tweak_changelogs.sh
chmod +x .github/tweak_changelogs.sh
.github/tweak_changelogs.sh beta
# The hash suffix will help identifying if the beta version is up-to-date
- name: Add commit hash suffix to manifest version
if: steps.tweak-changelogs.outcome == 'success'
run: |
sed -i "s/<Version number=\"\([^\"]*\)\"/<Version number=\"\1-$(git rev-parse --short HEAD)\"/g" manifest.xml
- name: Update manifest.xml
run: python3 update_manifest.py --quiet --in-place
- name: Push to beta branch
Expand Down