2023-08-31 10:41:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-09-26 07:08:29 +00:00
|
|
|
# THIS SCRIPT IS BROKEN HENCE DISABLED FTM
|
|
|
|
# This script is getting the latest release notes from the wiki and add them to the appdata
|
|
|
|
|
2023-08-31 10:41:25 +00:00
|
|
|
source automation_tools/version_extractor.sh
|
|
|
|
|
|
|
|
# Fetch appdata version
|
|
|
|
appdata_version=$(fetch_appdata_version)
|
|
|
|
echo -e "Appdata:\t\t$appdata_version"
|
|
|
|
|
|
|
|
# Defining manifest file location
|
|
|
|
appdata_file="net.retrodeck.retrodeck.appdata.xml"
|
|
|
|
|
2023-08-31 12:32:36 +00:00
|
|
|
# Check if release with appdata_version already exists
|
|
|
|
if grep -q "version=\"$appdata_version\"" "$appdata_file"; then
|
|
|
|
echo "Deleting existing release version $appdata_version..."
|
|
|
|
|
|
|
|
# Remove the existing release entry
|
|
|
|
sed -i "/<release version=\"$appdata_version\"/,/<\/release>/d" "$appdata_file"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Adding new release version $appdata_version..."
|
2023-08-31 10:41:25 +00:00
|
|
|
|
2023-08-31 12:32:36 +00:00
|
|
|
# Get today's date in the required format (YYYY-MM-DD)
|
|
|
|
today_date=$(date +"%Y-%m-%d")
|
|
|
|
echo "Today is $today_date"
|
|
|
|
|
|
|
|
# Construct the release snippet
|
|
|
|
release_snippet="\
|
2023-08-31 10:41:25 +00:00
|
|
|
<releases>
|
2023-08-31 12:32:36 +00:00
|
|
|
<release version=\"$appdata_version\" date=\"$today_date\">
|
|
|
|
<url>https://github.com/XargonWan/RetroDECK/releases/tag/$appdata_version</url>
|
2023-08-31 10:41:25 +00:00
|
|
|
<description>
|
|
|
|
RELEASE_NOTES_PLACEHOLDER
|
|
|
|
</description>
|
|
|
|
</release>"
|
|
|
|
|
2023-08-31 12:32:36 +00:00
|
|
|
# Read the entire content of the XML file
|
|
|
|
xml_content=$(cat "$appdata_file")
|
|
|
|
|
|
|
|
# Replace RELEASE_NOTES_PLACEHOLDER with the actual release notes
|
|
|
|
# TODO
|
|
|
|
git clone https://github.com/XargonWan/RetroDECK.wiki.git /tmp/wiki
|
|
|
|
|
|
|
|
# Path to the markdown file
|
|
|
|
wiki="/tmp/wiki/Version-history:-Patch-Notes.md"
|
|
|
|
# Read the markdown file until the first occurrence of "---"
|
|
|
|
latest_version_notes=""
|
|
|
|
while IFS= read -r line; do
|
|
|
|
if [ "$line" = "---" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
latest_version_notes+="$line\n"
|
|
|
|
done < "$wiki"
|
|
|
|
|
|
|
|
# Extract the version number
|
|
|
|
version_number="${latest_version_notes#*# RetroDECK }" # Remove text before "# RetroDECK "
|
|
|
|
version_number="${version_number%% -*}" # Remove text after " - "
|
|
|
|
|
|
|
|
# Extract sections from the latest version notes
|
|
|
|
sections=$(echo "$latest_version_notes" | awk '/##/ { print; }')
|
2023-08-31 10:41:25 +00:00
|
|
|
|
2023-08-31 12:43:38 +00:00
|
|
|
# Create a formatted section list
|
|
|
|
section_list=""
|
2023-08-31 12:32:36 +00:00
|
|
|
current_section=""
|
2023-08-31 12:43:38 +00:00
|
|
|
while IFS= read -r line; do
|
|
|
|
if [[ "$line" == "##"* ]]; then
|
2023-08-31 12:32:36 +00:00
|
|
|
if [ -n "$current_section" ]; then
|
2023-08-31 12:43:38 +00:00
|
|
|
section_list+="</ul>"
|
2023-08-31 12:32:36 +00:00
|
|
|
fi
|
2023-08-31 12:43:38 +00:00
|
|
|
section_name="${line##*# }"
|
|
|
|
section_list+="<p>${section_name}</p><ul>"
|
|
|
|
elif [[ "$line" == "- "* ]]; then
|
|
|
|
entry="${line#*- }"
|
|
|
|
section_list+="<li>${entry}</li>"
|
2023-08-31 12:32:36 +00:00
|
|
|
fi
|
2023-08-31 12:43:38 +00:00
|
|
|
done <<< "$sections"
|
2023-08-31 12:32:36 +00:00
|
|
|
|
2023-08-31 12:43:38 +00:00
|
|
|
if [ -n "$current_section" ]; then
|
|
|
|
section_list+="</ul>"
|
|
|
|
fi
|
2023-08-31 12:32:36 +00:00
|
|
|
|
|
|
|
# Replace RELEASE_NOTES_PLACEHOLDER with the actual release notes
|
|
|
|
release_description="${release_snippet/RELEASE_NOTES_PLACEHOLDER/$section_list}"
|
|
|
|
|
|
|
|
# Append the new release snippet to the content
|
|
|
|
modified_xml_content="${xml_content/<releases>/$release_description}"
|
|
|
|
|
|
|
|
# Overwrite the original XML file with the modified content
|
|
|
|
echo "$modified_xml_content" > "$appdata_file"
|
|
|
|
|
|
|
|
# Format the XML file
|
|
|
|
#xmlstarlet fo --omit-decl "$appdata_file"
|