mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
Fix 'Update changelog.md on Release' Workflow (#2410)
* A Fix for 'createchangelog.yml' & Rename File 'updates.md' to 'changelog.md' * Fix GitHub CLI Not Working * Increase the limit for Release List to 1000000 * Add '--exclude-drafts' & '--exclude-pre-releases' to GitHub CLI Release List Command * Rewrite Bash Script found in a step of 'Update changelog.md on Release' GitHub Workflow * Change the Content Generation a bit in 'Update changelog.md on Release' GitHub Workflow * Reorder the Content Generation in 'Update changelog.md on Release' GitHub Workflow * Update Regex for 'Update changelog.md on Release' Worflow * Change the Release Event Types to 'Published, Edited, Created, Deleted' to ensure the Changelog is Up-To-Date
This commit is contained in:
parent
706328e674
commit
363ed1c41b
107
.github/workflows/createchangelog.yml
vendored
107
.github/workflows/createchangelog.yml
vendored
@ -1,8 +1,8 @@
|
||||
name: Update update.mb on Release
|
||||
name: Update changelog.md on Release
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published, prereleased]
|
||||
types: [published, created, edited, deleted]
|
||||
workflow_dispatch: # Add this line to enable manual triggering
|
||||
|
||||
jobs:
|
||||
@ -13,23 +13,94 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get all releases and update update.mb file
|
||||
- name: Get all releases and update changelog.md file
|
||||
run: |
|
||||
# Fetch all releases including pre-releases using GitHub CLI
|
||||
gh release list --limit 5 > releases.txt
|
||||
|
||||
# Extract numeric versions and create update.mb content
|
||||
echo "" > docs/update.mb
|
||||
# Initialize some values
|
||||
changelog_path="docs/changelog.md"
|
||||
gh release list --exclude-drafts --json tagName,name,isLatest,isPrerelease --limit 1000000 > releases.txt
|
||||
declare -rA number_of_releases=$(cat releases.txt | grep -Po '"tagName"' | wc --lines)
|
||||
|
||||
# Clear the contents of changelog file
|
||||
echo "" > $changelog_path
|
||||
|
||||
# Write some Initial Content to changelog file
|
||||
echo "# Changelog" >> $changelog_path
|
||||
echo "" >> $changelog_path
|
||||
echo "WinUtil change log received from GitHub Releases, it's autogenerated using GitHub Actions." >> $changelog_path
|
||||
echo "" >> $changelog_path
|
||||
echo "> [!WARNING]" >> $changelog_path
|
||||
echo "> This file **SHOULD NOT** be edited directly, any PRs that tries changing it directly will either be requested on not changing it, or it'll get rejected." >> $changelog_path
|
||||
echo "" >> $changelog_path
|
||||
|
||||
# Make array for git tag names
|
||||
tag_arr=()
|
||||
cat releases.txt | grep -Po '"tagName":\s*.*?[^\\]"' | awk -F ':' '{print $2}' | sed s/\"//g > tags_list.txt
|
||||
while read -r line; do
|
||||
tag=$(echo "$line" | awk '{print $1}')
|
||||
name=$(echo "$line" | awk -F'\t' '{print $2}')
|
||||
version_numeric=$(echo "$tag" | grep -o -E '[0-9.]+')
|
||||
tag_arr+=("$line")
|
||||
done < tags_list.txt
|
||||
|
||||
# Make array for releases names
|
||||
name_arr=()
|
||||
cat releases.txt | grep -Po '"name":\s*.*?[^\\]"' | awk -F ':' '{print $2}' | sed s/\"//g > releases_names_list.txt
|
||||
while read -r line; do
|
||||
name_arr+=("$line")
|
||||
done < releases_names_list.txt
|
||||
|
||||
# Make array for isPrerelease
|
||||
isprerelease_arr=()
|
||||
cat releases.txt | grep -Po '"isPrerelease":\s*(false|true)' | awk -F ':' '{print $2}' | sed s/\"//g > isprerelease_list.txt
|
||||
while read -r line; do
|
||||
isprerelease_arr+=("$line")
|
||||
done < isprerelease_list.txt
|
||||
|
||||
# Make array for isLatest
|
||||
islatest_arr=()
|
||||
cat releases.txt | grep -Po '"isLatest":\s*(false|true)' | awk -F ':' '{print $2}' | sed s/\"//g > islatest_list.txt
|
||||
while read -r line; do
|
||||
islatest_arr+=("$line")
|
||||
done < islatest_list.txt
|
||||
|
||||
# Debug Output
|
||||
echo "Tag Array: " ${tag_arr[@]}
|
||||
echo "Array Length: " ${#tag_arr[@]}
|
||||
echo ""
|
||||
|
||||
echo "Release Name Array: " ${name_arr[@]}
|
||||
echo "Array Length: " ${#name_arr[@]}
|
||||
echo ""
|
||||
|
||||
echo "IsPrerelease Array: " ${isprerelease_arr[@]}
|
||||
echo "Array Length: " ${#isprerelease_arr[@]}
|
||||
echo ""
|
||||
|
||||
echo "IsLatest Array: " ${islatest_arr[@]}
|
||||
echo "Array Length: " ${#islatest_arr[@]}
|
||||
echo ""
|
||||
|
||||
# Exit when this impossible condition is met (just to be safe)
|
||||
if [[ ! (${#tag_arr[@]}==${#name_arr[@]} && ${#tag_arr[@]}==${#isprerelease_arr[@]} && ${#tag_arr[@]}==${#islatest_arr[@]} ) ]] ; then
|
||||
echo "Impossible Condition has been met, the Name Array Length Does Not match Tag Array Length, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Main loop that does the heavy lifting (Content Generation)
|
||||
for (( i=0; i<${number_of_releases}; i++ ));
|
||||
do
|
||||
# The Variables to use on each iteration
|
||||
tag=${tag_arr[$i]}
|
||||
name=${name_arr[$i]}
|
||||
isprerelease=${isprerelease_arr[$i]}
|
||||
islatest=${islatest_arr[$i]}
|
||||
body=$(gh release view "$tag" --json body --jq .body)
|
||||
echo "## $version_numeric" >> docs/update.mb
|
||||
echo "Release name: $name" >> docs/update.mb
|
||||
echo "Release body: $body" >> docs/update.mb
|
||||
echo "" >> docs/update.mb
|
||||
done < releases.txt
|
||||
|
||||
# The generation of changelog file contents
|
||||
echo "# $name" >> $changelog_path
|
||||
echo "" >> $changelog_path
|
||||
echo "$body" >> $changelog_path
|
||||
echo "" >> $changelog_path
|
||||
done
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Commit and Push Changes
|
||||
env:
|
||||
@ -37,6 +108,6 @@ jobs:
|
||||
run: |
|
||||
git config --global user.name 'github-actions[bot]'
|
||||
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||
git add docs/update.mb
|
||||
git commit -m "Update update.mb with all releases"
|
||||
git add docs/changelog.md
|
||||
git commit -m "Update changelog.md with all releases"
|
||||
git push
|
||||
|
@ -5,7 +5,7 @@ nav:
|
||||
- Introduction: 'index.md'
|
||||
- User Guide: 'userguide.md'
|
||||
- Contribute: 'contribute.md'
|
||||
- Updates: 'updates.md'
|
||||
- Changelog: 'changelog.md'
|
||||
- Known Issues: 'KnownIssues.md'
|
||||
- FAQ: 'faq.md'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user