diff --git a/automation_tools/appdata_management.sh b/automation_tools/appdata_management.sh index 5a546595..29fa7cf5 100755 --- a/automation_tools/appdata_management.sh +++ b/automation_tools/appdata_management.sh @@ -5,42 +5,123 @@ source automation_tools/version_extractor.sh # Fetch appdata version appdata_version=$(fetch_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 appdata_file="net.retrodeck.retrodeck.appdata.xml" -# Check if release with manifest_version already exists -if grep -q "version=\"$manifest_version\"" "$appdata_file"; then - echo "The release notes for the latest version are already present in the appdata" -else - # Get today's date in the required format (YYYY-MM-DD) - today_date=$(date +"%Y-%m-%d") - echo "Today is $today_date" +# 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 "//d" "$appdata_file" +fi - # Construct the release snippet - release_snippet="\ +echo "Adding new release version $appdata_version..." + +# 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="\ - - https://github.com/XargonWan/RetroDECK/releases/tag/$manifest_version + + https://github.com/XargonWan/RetroDECK/releases/tag/$appdata_version RELEASE_NOTES_PLACEHOLDER " - # Read the entire content of the XML file - xml_content=$(cat "$appdata_file") +# Read the entire content of the XML file +xml_content=$(cat "$appdata_file") - # Replace RELEASE_NOTES_PLACEHOLDER with the actual release notes - # TODO +# Replace RELEASE_NOTES_PLACEHOLDER with the actual release notes +# TODO +git clone https://github.com/XargonWan/RetroDECK.wiki.git /tmp/wiki - # Append the new release snippet to the content - modified_xml_content="${xml_content//$release_snippet}" +# 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" - # Overwrite the original XML file with the modified content - echo "$modified_xml_content" > "$appdata_file" +# 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; }') + +# # 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+="" +# fi +# section_name="${line##*# }" +# section_list+="

${section_name}

    " +# elif [[ "$line" == "- "* ]]; then +# entry="${line#*- }" +# section_list+="
  • ${entry}
  • " +# fi +# done <<< "$sections" + +# if [ -n "$current_section" ]; then +# section_list+="
" +# 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+="\n" + in_list=0 + fi + altered_sections+="\n" + fi + current_section="${BASH_REMATCH[1]}" + altered_sections+="

$current_section

\n
    \n" + elif [[ $line =~ ^-\ (.+) ]]; then + if [ $in_list -eq 0 ]; then + in_list=1 + altered_sections+="
      \n" + fi + list_item="${BASH_REMATCH[1]}" + altered_sections+="
    • $list_item
    • \n" + elif [ -z "$line" ]; then + if [ $in_list -eq 1 ]; then + in_list=0 + altered_sections+="
    \n" + fi + fi +done +if [ $in_list -eq 1 ]; then + altered_sections+="
\n" fi - # Format the XML file - xmlstarlet fo --omit-decl "$appdata_file" \ No newline at end of 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//$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" diff --git a/force-update-submodules.sh b/automation_tools/force-update-submodules.sh similarity index 93% rename from force-update-submodules.sh rename to automation_tools/force-update-submodules.sh index 57d3df5f..c0c84f46 100644 --- a/force-update-submodules.sh +++ b/automation_tools/force-update-submodules.sh @@ -1,5 +1,7 @@ #!/bin/bash +# Don't use this script lightly + git submodule deinit --all rm rd-submodules/retroarch git rm -rf --cached rd-submodules/retroarch diff --git a/automation_tools/pre_build_automation.sh b/automation_tools/pre_build_automation.sh old mode 100644 new mode 100755 diff --git a/removed-modules.yml b/old/removed-modules.yml similarity index 100% rename from removed-modules.yml rename to old/removed-modules.yml diff --git a/.github/workflows/removed/TEST_release_info.yml b/old/workflows/TEST_release_info.yml similarity index 100% rename from .github/workflows/removed/TEST_release_info.yml rename to old/workflows/TEST_release_info.yml diff --git a/.github/workflows/removed/cooker.yml b/old/workflows/cooker.yml similarity index 100% rename from .github/workflows/removed/cooker.yml rename to old/workflows/cooker.yml diff --git a/.github/workflows/removed/flathub_push_cooker.yml b/old/workflows/flathub_push_cooker.yml similarity index 100% rename from .github/workflows/removed/flathub_push_cooker.yml rename to old/workflows/flathub_push_cooker.yml diff --git a/.github/workflows/removed/main.yml b/old/workflows/main.yml similarity index 100% rename from .github/workflows/removed/main.yml rename to old/workflows/main.yml diff --git a/.github/workflows/removed/remove-artifacts.yml b/old/workflows/remove-artifacts.yml similarity index 100% rename from .github/workflows/removed/remove-artifacts.yml rename to old/workflows/remove-artifacts.yml