aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/buildrelease.yml
diff options
context:
space:
mode:
authorYasin <LifeIsAParadox@users.noreply.github.com>2023-06-25 11:38:03 +0200
committerGitHub <noreply@github.com>2023-06-25 05:38:03 -0400
commitcfc0ecf96ef179b0cac0b31e90eca6e86fe2488e (patch)
treeb16372605042ccee155e5fd3d1be9e8b4b03f9d1 /.github/workflows/buildrelease.yml
parent9d71ef0f17197db692a45be9be3866d4573c9621 (diff)
downloadSkyblocker-cfc0ecf96ef179b0cac0b31e90eca6e86fe2488e.tar.gz
Skyblocker-cfc0ecf96ef179b0cac0b31e90eca6e86fe2488e.tar.bz2
Skyblocker-cfc0ecf96ef179b0cac0b31e90eca6e86fe2488e.zip
Workflow fix discord character limit (#180)
* limit to 2000 char max because discord * Update buildrelease.yml
Diffstat (limited to '.github/workflows/buildrelease.yml')
-rw-r--r--.github/workflows/buildrelease.yml42
1 files changed, 41 insertions, 1 deletions
diff --git a/.github/workflows/buildrelease.yml b/.github/workflows/buildrelease.yml
index 4361f363..d79c40e8 100644
--- a/.github/workflows/buildrelease.yml
+++ b/.github/workflows/buildrelease.yml
@@ -39,11 +39,51 @@ jobs:
id: read_changelog
shell: bash
run: |
- CHANGELOG=$(sed '/___/Q' CHANGELOG.md | grep -v '# ')
+ CHANGELOG=$(sed '/___/Q' CHANGELOG.md)
echo "Changelog:\n$CHANGELOG"
+
+ changelog="${CHANGELOG}"
+
+ # Because of the 2000 char limit in Discord shorten the changelog
+
+ # Calculate the number of characters to delete
+ delete_chars=$((${#changelog} + 350 - 2000 - 15))
+
+ # Check if delete_chars is greater than 0
+ if [ $delete_chars -gt 0 ]; then
+
+ # Extract the "What's Changed" section from the changelog
+ changed_section=$(echo "$changelog" | awk '/## What'\''s Changed/{flag=1;next}/^$/{flag=0}flag')
+
+ # Trim the changed_section based on the delete_chars value and remove the last line
+ modified_section="${changed_section::-delete_chars}"
+ modified_section=$(echo "$modified_section" | sed '$d')
+
+ # Add "[...] and more" at the end of modified_section
+ modified_section+="\n[...] and more"
+
+ # Format modified_section with printf
+ modified_section=$(printf "%s" "$modified_section")
+
+ # Generate the modified_changelog by inserting modified_section after the "What's Changed" section
+ modified_changelog=$(awk -v modified_section="$modified_section" '
+ /^## What'\''s Changed/ { print; print modified_section; f=1; next }
+ f && /^$/ { f=0 }
+ !f { print }
+ END { if (f) print "" }
+ ' ORS='\n' <<< "$changelog")
+
+ # Format the modified_changelog by removing "@" characters and enclosing URLs in "<>"
+ modified_changelog=$(echo "$modified_changelog" | sed -e 's/@//g' -e 's|https\?://[^[:space:]]*|<\0>|g')
+
+ # Store the modified_changelog in the CHANGELOG variable
+ CHANGELOG=$(echo -n "$modified_changelog")
+ fi
+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
+
echo "::set-output name=changelog::$CHANGELOG"
- uses: actions/github-script@v2