Skip to content

Commit 0029db8

Browse files
committed
Generate the changelog for the beta releases
1 parent 7e512dc commit 0029db8

File tree

3 files changed

+65
-21
lines changed

3 files changed

+65
-21
lines changed

.github/tweak_changelogs.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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

.github/workflows/beta.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ jobs:
2020
run: |
2121
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
2222
git config --global user.name "github-actions[bot]"
23+
# The hash suffix will help identifying if the beta version is up-to-date
24+
- name: Add commit hash suffix to manifest version
25+
run: |
26+
sed -i "s/<Version number=\"\([^\"]*\)\"/<Version number=\"\1-$(git rev-parse --short HEAD)\"/g" manifest.xml
27+
- name: Generate Release notes
28+
run: |
29+
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
30+
# Delete existing beta draft if it exists
31+
if gh release view beta >/dev/null 2>&1; then
32+
gh release delete beta --yes
33+
fi
34+
# Create new beta draft release with generated notes
35+
gh release create beta --title "Beta Release" --draft --generate-notes
36+
gh release view beta > temp_change.md
37+
- name: Tweak changelogs
38+
run: |
39+
# Remove carriage returns to be able to run the script
40+
sed -i 's/\r$//' .github/tweak_changelogs.sh
41+
chmod +x .github/tweak_changelogs.sh
42+
.github/tweak_changelogs.sh beta
2343
- name: Update manifest.xml
2444
run: python3 update_manifest.py --quiet --in-place
2545
- name: Push to beta branch

.github/workflows/release.yml

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,11 @@ jobs:
2929
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token;
3030
gh release view $(basename ${{ github.event.inputs.releaseNoteUrl }}) > temp_change.md
3131
- name: Tweak changelogs
32-
run: >
33-
sed -i '1,10d' temp_change.md;
34-
sed -i '1h;1d;$!H;$!d;G' temp_change.md;
35-
sed -i -re 's/\*\*Full Changelog\*\*: (.*)/\[Full Changelog\]\(\1\)\n/' temp_change.md;
36-
sed -i '/## New Contributors/,$d' temp_change.md;
37-
sed -i -re 's/^\*(.*)\sby\s@(.*)\sin\s(.*\/pull\/)(.*)\r?/-\1 [\\#\4](\3\4) ([\2](https:\/\/github.com\/\2))/' temp_change.md;
38-
sed -i 's/\[Quotae/\[Quote_a/' temp_change.md;
39-
sed -i 's/\[learn2draw/\[Lexy/' temp_change.md;
40-
sed -i 's/\[Voronoff/\[Tom Clancy Is Dead/' temp_change.md;
41-
sed -i 's/\[PJacek/\[TPlant/' temp_change.md;
42-
sed -i 's/\[justjuangui/\[trompetin17/' temp_change.md;
43-
sed -i 's/\r//g' temp_change.md;
44-
cp temp_change.md changelog_temp.txt;
45-
cat CHANGELOG.md | tr \\r \\n | sed '1d' >> temp_change.md;
46-
printf "# Changelog\n\n## [v${{ github.event.inputs.releaseVersion }}](https://github.com/PathOfBuildingCommunity/PathOfBuilding/tree/v${{ github.event.inputs.releaseVersion }}) ($(date +'%Y/%m/%d'))\n\n" | cat - temp_change.md > CHANGELOG.md;
47-
48-
sed -i -re 's/^- (.*) \[.*\) \(\[(.*)\]\(.*/* \1 (\2)/' changelog_temp.txt;
49-
echo "VERSION[${{ github.event.inputs.releaseVersion }}][`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;
50-
rm temp_change.md;
51-
rm changelog_temp.txt;
52-
mv changelog_new.txt changelog.txt
32+
run: |
33+
# Remove carriage returns to be able to run the script
34+
sed -i 's/\r$//' .github/tweak_changelogs.sh
35+
chmod +x .github/tweak_changelogs.sh
36+
.github/tweak_changelogs.sh "v${{ github.event.inputs.releaseVersion }}"
5337
- name: Create Pull Request
5438
uses: peter-evans/create-pull-request@v5
5539
with:

0 commit comments

Comments
 (0)