Repo cleanup [skip ci]

This commit is contained in:
XargonWan 2023-08-31 14:32:36 +02:00
parent 08698cf63a
commit aa2a2b453b
9 changed files with 107 additions and 24 deletions

View file

@ -5,42 +5,123 @@ source automation_tools/version_extractor.sh
# Fetch appdata version # Fetch appdata version
appdata_version=$(fetch_appdata_version) appdata_version=$(fetch_appdata_version)
echo -e "Appdata:\t\t$appdata_version" echo -e "Appdata:\t\t$appdata_version"
# Fetch manifest version
manifest_version=$(fetch_manifest_version)
echo -e "Manifest:\t\t$manifest_version"
# Defining manifest file location # Defining manifest file location
appdata_file="net.retrodeck.retrodeck.appdata.xml" appdata_file="net.retrodeck.retrodeck.appdata.xml"
# Check if release with manifest_version already exists # Check if release with appdata_version already exists
if grep -q "version=\"$manifest_version\"" "$appdata_file"; then if grep -q "version=\"$appdata_version\"" "$appdata_file"; then
echo "The release notes for the latest version are already present in the appdata" echo "Deleting existing release version $appdata_version..."
else
# Get today's date in the required format (YYYY-MM-DD) # Remove the existing release entry
today_date=$(date +"%Y-%m-%d") sed -i "/<release version=\"$appdata_version\"/,/<\/release>/d" "$appdata_file"
echo "Today is $today_date" fi
# Construct the release snippet echo "Adding new release version $appdata_version..."
release_snippet="\
# 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="\
<releases> <releases>
<release version=\"$manifest_version\" date=\"$today_date\"> <release version=\"$appdata_version\" date=\"$today_date\">
<url>https://github.com/XargonWan/RetroDECK/releases/tag/$manifest_version</url> <url>https://github.com/XargonWan/RetroDECK/releases/tag/$appdata_version</url>
<description> <description>
RELEASE_NOTES_PLACEHOLDER RELEASE_NOTES_PLACEHOLDER
</description> </description>
</release>" </release>"
# Read the entire content of the XML file # Read the entire content of the XML file
xml_content=$(cat "$appdata_file") xml_content=$(cat "$appdata_file")
# Replace RELEASE_NOTES_PLACEHOLDER with the actual release notes # Replace RELEASE_NOTES_PLACEHOLDER with the actual release notes
# TODO # TODO
git clone https://github.com/XargonWan/RetroDECK.wiki.git /tmp/wiki
# Append the new release snippet to the content # Path to the markdown file
modified_xml_content="${xml_content/<releases>/$release_snippet}" 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"
# Overwrite the original XML file with the modified content # Extract the version number
echo "$modified_xml_content" > "$appdata_file" 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; }')
# # Create a formatted section list
# section_list=""
# current_section=""
# while IFS= read -r line; do
# if [[ "$line" == "##"* ]]; then
# if [ -n "$current_section" ]; then
# section_list+="</ul>"
# fi
# section_name="${line##*# }"
# section_list+="<p>${section_name}</p><ul>"
# elif [[ "$line" == "- "* ]]; then
# entry="${line#*- }"
# section_list+="<li>${entry}</li>"
# fi
# done <<< "$sections"
# if [ -n "$current_section" ]; then
# section_list+="</ul>"
# fi
altered_sections=""
current_section=""
in_list=0
IFS=$'\n'
for line in $sections; do
if [[ $line =~ ^##\ (.+) ]]; then
if [ -n "$current_section" ]; then
if [ $in_list -eq 1 ]; then
altered_sections+="</ul>\n"
in_list=0
fi
altered_sections+="</ul>\n"
fi
current_section="${BASH_REMATCH[1]}"
altered_sections+="<p>$current_section</p>\n<ul>\n"
elif [[ $line =~ ^-\ (.+) ]]; then
if [ $in_list -eq 0 ]; then
in_list=1
altered_sections+="<ul>\n"
fi
list_item="${BASH_REMATCH[1]}"
altered_sections+="<li>$list_item</li>\n"
elif [ -z "$line" ]; then
if [ $in_list -eq 1 ]; then
in_list=0
altered_sections+="</ul>\n"
fi
fi
done
if [ $in_list -eq 1 ]; then
altered_sections+="</ul>\n"
fi fi
# Format the XML file
xmlstarlet fo --omit-decl "$appdata_file" echo -e "$altered_sections"
# 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"

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# Don't use this script lightly
git submodule deinit --all git submodule deinit --all
rm rd-submodules/retroarch rm rd-submodules/retroarch
git rm -rf --cached rd-submodules/retroarch git rm -rf --cached rd-submodules/retroarch

0
automation_tools/pre_build_automation.sh Normal file → Executable file
View file