From af91f4de2a9a6aa3fe4758cc003ed108975787c8 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Wed, 24 Jul 2024 20:33:47 +0900 Subject: [PATCH] PRE_BUILD_AUTOMATION: adding new sha function --- automation_tools/automation_task_list.cfg | 36 +++++++++------- automation_tools/pre_build_automation.sh | 52 ++++++++++++++++++----- net.retrodeck.retrodeck.yml | 2 +- 3 files changed, 63 insertions(+), 27 deletions(-) diff --git a/automation_tools/automation_task_list.cfg b/automation_tools/automation_task_list.cfg index e10bef57..df27ec5a 100644 --- a/automation_tools/automation_task_list.cfg +++ b/automation_tools/automation_task_list.cfg @@ -2,9 +2,11 @@ # ACTION^PLACEHOLDERTEXT^URL^REPO(Optional) # hash^DOOMSHAPLACEHOLDER^https://buildbot.libretro.com/assets/cores/DOOM/Doom%20%28Shareware%29.zip # Please leave some newlines in the end of this file or it will break + latestcommit^UNIVERSALDYNAMICINPUTCOMMITPLACEHOLDER^https://github.com/Venomalia/UniversalDynamicInput^main outside_file^VERSIONPLACEHOLDER^${GITHUB_WORKSPACE}/buildid branch^THISBRANCH + hash^RASHAPLACEHOLDER^https://buildbot.libretro.com/nightly/linux/x86_64/RetroArch.7z hash^SAMEDUCKSHAPLACEHOLDER^https://buildbot.libretro.com/nightly/linux/x86_64/latest/sameduck_libretro.so.zip hash^PPSSPPBIOSHASHPLACEHOLDER^https://github.com/hrydgard/ppsspp/archive/refs/heads/master.zip @@ -12,19 +14,21 @@ hash^MSXBIOSHASHPLACEHOLDER^http://bluemsx.msxblue.com/rel_download/blueMSXv282f hash^XEMUHDDHASHPLACEHOLDER^https://github.com/mborgerson/xemu-hdd-image/releases/latest/download/xbox_hdd.qcow2.zip hash^VITA3KSHAPLACEHOLDER^https://github.com/Vita3K/Vita3K/releases/download/continuous/ubuntu-latest.zip hash^RANIGHTLYCORESPLACEHOLDER^https://buildbot.libretro.com/nightly/linux/x86_64/RetroArch_cores.7z -hash^RETRODECKMAMEPLACEHOLDER^"https://github.com/XargonWan/RetroDECK-MAME/releases/download/$(curl -s https://api.github.com/repos/XargonWan/RetroDECK-MAME/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-MAME-Artifact.tar.gz" -url^RETRODECKMAMEURLPLACEHOLDER^"https://github.com/XargonWan/RetroDECK-MAME/releases/download/$(curl -s https://api.github.com/repos/XargonWan/RetroDECK-MAME/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-MAME-Artifact.tar.gz" -url^RETRODECKESDEURLPLACEHOLDER^"https://github.com/RetroDECK/ES-DE/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/ES-DE/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-ES-DE-Artifact.tar.gz" -hash^RETRODECKESDEPLACEHOLDER^"https://github.com/RetroDECK/ES-DE/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/ES-DE/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-ES-DE-Artifact.tar.gz" -url^RETRODECKPPSSPPURL^"https://github.com/RetroDECK/org.ppsspp.PPSSPP/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.ppsspp.PPSSPP/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-PPSSPP-Artifact.tar.gz" -hash^RETRODECKPPSSPPHASH^"https://github.com/RetroDECK/org.ppsspp.PPSSPP/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.ppsspp.PPSSPP/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-PPSSPP-Artifact.tar.gz" -url^RETRODECKDOLPHINURLPLACEHOLDER^"https://github.com/RetroDECK/org.DolphinEmu.dolphin-emu/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.DolphinEmu.dolphin-emu/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-dolphin-Artifact.tar.gz" -hash^RETRODECKDOLPHINPLACEHOLDER^"https://github.com/RetroDECK/org.DolphinEmu.dolphin-emu/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.DolphinEmu.dolphin-emu/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-dolphin-Artifact.tar.gz" -url^RETRODECKSOLARUSURLPLACEHOLDER^"https://github.com/RetroDECK/org.solarus_games.solarus.Launcher/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.solarus_games.solarus.Launcher/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-solarus-Artifact.tar.gz" -hash^RETRODECKSOLARUSPLACEHOLDER^"https://github.com/RetroDECK/org.solarus_games.solarus.Launcher/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.solarus_games.solarus.Launcher/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-solarus-Artifact.tar.gz" -url^RETRODECKPRIMEHACKURLPLACEHOLDER^"https://github.com/RetroDECK/io.github.shiiion.primehack/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/io.github.shiiion.primehack/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-primehack-Artifact.tar.gz" -hash^RETRODECKPRIMEHACKPLACEHOLDER^"https://github.com/RetroDECK/io.github.shiiion.primehack/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/io.github.shiiion.primehack/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-primehack-Artifact.tar.gz" -url^RETRODECKGZDOOMSURLPLACEHOLDER^"https://github.com/RetroDECK/org.zdoom.GZDoom/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.zdoom.GZDoom/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-gzdoom-Artifact.tar.gz" -hash^RETRODECKGZDOOMSHASPLACEHOLDER^"https://github.com/RetroDECK/org.zdoom.GZDoom/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/org.zdoom.GZDoom/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-gzdoom-Artifact.tar.gz" -url^RETRODECKMELONDSURLPLACEHOLDER^"https://github.com/RetroDECK/net.kuribo64.melonDS/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/net.kuribo64.melonDS/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-melonds-Artifact.tar.gz" -hash^RETRODECKMELONDSSHAPLACEHOLDER^"https://github.com/RetroDECK/net.kuribo64.melonDS/releases/download/$(curl -s https://api.github.com/repos/RetroDECK/net.kuribo64.melonDS/releases/latest | grep -oP '"tag_name": "\K(.*?)(?=")')/RetroDECK-melonds-Artifact.tar.gz" + +latestghreleasesha^RETRODECKMAMEPLACEHOLDER^https://api.github.com/repos/RetroDECK/RetroDECK-MAME/releases/latest^RetroDECK-MAME-Artifact.tar.gz +latestghreleasesha^RETRODECKESDEPLACEHOLDER^https://api.github.com/repos/RetroDECK/ES-DE/releases/latest^RetroDECK-ES-DE-Artifact.tar.gz +latestghreleasesha^RETRODECKPPSSPPHASH^https://api.github.com/repos/RetroDECK/org.ppsspp.PPSSPP/releases/latest^RetroDECK-PPSSPP-Artifact.tar.gz +latestghreleasesha^RETRODECKDOLPHINPLACEHOLDER^https://api.github.com/repos/RetroDECK/org.DolphinEmu.dolphin-emu/releases/latest^RetroDECK-dolphin-Artifact.tar.gz +latestghreleasesha^RETRODECKSOLARUSPLACEHOLDER^https://api.github.com/repos/RetroDECK/org.solarus_games.solarus.Launcher/releases/latest^RetroDECK-solarus-Artifact.tar.gz +latestghreleasesha^RETRODECKPRIMEHACKPLACEHOLDER^https://api.github.com/repos/RetroDECK/io.github.shiiion.primehack/releases/latest^RetroDECK-primehack-Artifact.tar.gz +latestghreleasesha^RETRODECKGZDOOMSHASPLACEHOLDER^https://api.github.com/repos/RetroDECK/org.zdoom.GZDoom/releases/latest^RetroDECK-gzdoom-Artifact.tar.gz +latestghreleasesha^RETRODECKMELONDSSHAPLACEHOLDER^https://api.github.com/repos/RetroDECK/net.kuribo64.melonDS/releases/latest^RetroDECK-melonds-Artifact.tar.gz + +latestghrelease^RETRODECKMAMEURLPLACEHOLDER^https://api.github.com/repos/XargonWan/RetroDECK-MAME/releases/latest^RetroDECK-MAME-Artifact.tar.gz +latestghrelease^RETRODECKESDEURLPLACEHOLDER^https://api.github.com/repos/RetroDECK/ES-DE/releases/latest^RetroDECK-ES-DE-Artifact.tar.gz +latestghrelease^RETRODECKPPSSPPURL^https://api.github.com/repos/RetroDECK/org.ppsspp.PPSSPP/releases/latest^RetroDECK-PPSSPP-Artifact.tar.gz +latestghrelease^RETRODECKDOLPHINURLPLACEHOLDER^https://api.github.com/repos/RetroDECK/org.DolphinEmu.dolphin-emu/releases/latest^RetroDECK-dolphin-Artifact.tar.gz +latestghrelease^RETRODECKSOLARUSURLPLACEHOLDER^https://api.github.com/repos/RetroDECK/org.solarus_games.solarus.Launcher/releases/latest^RetroDECK-solarus-Artifact.tar.gz +latestghrelease^RETRODECKPRIMEHACKURLPLACEHOLDER^https://api.github.com/repos/RetroDECK/io.github.shiiion.primehack/releases/latest^RetroDECK-primehack-Artifact.tar.gz +latestghrelease^RETRODECKGZDOOMSURLPLACEHOLDER^https://api.github.com/repos/RetroDECK/org.zdoom.GZDoom/releases/latest^RetroDECK-gzdoom-Artifact.tar.gz +latestghrelease^RETRODECKMELONDSURLPLACEHOLDER^https://api.github.com/repos/RetroDECK/net.kuribo64.melonDS/releases/latest^RetroDECK-melonds-Artifact.tar.gz diff --git a/automation_tools/pre_build_automation.sh b/automation_tools/pre_build_automation.sh index e0724f17..3dabcc85 100755 --- a/automation_tools/pre_build_automation.sh +++ b/automation_tools/pre_build_automation.sh @@ -7,33 +7,35 @@ set -e # sh automation_tools/pre_build_automation.sh # Different actions need different information in the task list file # branch: This changes the placeholder text to the currently-detected GIT branch if an automated build was started from a PR environment. -# hash: Finds the SHA256 hash of a file online and updates the placeholder in the manifest. +# hash: Finds the SHA256 hash of a file online and updates the placeholder in the manifest. # Needs the URL of the file, in this line format: hash^PLACEHOLDERTEXT^url -# latestcommit: Finds the most recent commit of a git repo and updated the placeholder in the manifest. +# latestcommit: Finds the most recent commit of a git repo and updates the placeholder in the manifest. # Needs the URL of the repo and the branch to find the latest commit from, in this line format: latestcommit^PLACEHOLDERTEXT^url^branch # latestghtag: Finds the most recent tag on a GitHub repo, for repos that don't have normal releases, but also shouldn't use the latest commit # Needs the URL of the repo, in this line format: latestghtag^PLACEHOLDERTEXT^url # latestghrelease: Finds the download URL and SHA256 hash of the latest release from a git repo. -# Needs the API URL of the repo, in this line format: latestappimage^PLACEHOLDERTEXT^https://api.github.com/repos///releases/latest^ -# As this command updates two different placeholders (one for the URL, one for the file hash) in the manifest, +# Needs the API URL of the repo, in this line format: latestghrelease^PLACEHOLDERTEXT^https://api.github.com/repos///releases/latest^ +# As this command updates two different placeholders (one for the URL, one for the file hash) in the manifest, # the URL that would be used in the above example is "PLACEHOLDERTEXT" and the hash placeholder text would be "HASHPLACEHOLDERTEXT" -# The "HASH" prefix of the placeholder text is hardcoded in the script +# The "HASH" prefix of the hash placeholder text is hardcoded in the script. # The will be the file extension or other identifying suffix at the end of the file name that can be used to select from multiple releases. # Example: If there are these file options for a given release: # yuzu-mainline-20240205-149629642.AppImage # yuzu-linux-20240205-149629642-source.tar.xz -# yuzu-linux-20240205-149629642-debug.tar.xz +# yuzu-linux-20240205-149629642-debug.tar.xz # Entering "AppImage" (without quotes) for the will identify yuzu-mainline-20240205-149629642.AppImage # Entering "source-.tar.xz" (without quotes) for the will identify yuzu-linux-20240205-149629642-source.tar.xz # Entering "debug-tar.xz" (without quotes) for the will identify yuzu-linux-20240205-149629642-debug.tar.xz -# As a file extension like ".tar.zx" can apply to multiple file options, the entire part that is appended to each release name should be included. +# As a file extension like ".tar.xz" can apply to multiple file options, the entire part that is appended to each release name should be included. # The will also only consider entries where the given suffix is at the end of the file name. So "AppImage" will identify "file.AppImage" but not "file.AppImage.zsync" +# latestghreleasesha: Finds the SHA256 hash of a specific asset in the latest release from a git repo. +# Needs the API URL of the repo, in this line format: latestghreleasesha^PLACEHOLDERTEXT^https://api.github.com/repos///releases/latest^ +# This command updates the placeholder in the manifest with the SHA256 hash of the specified asset. # outside_file: Prints the contents of a file from the build environment (such as the buildid file) and replaces the placeholder text with those contents. # outside_env_var: Gets the value of an environmental variable from the build environment (the output of "echo $var" from the terminal) and replaces the placeholder text with that value. -# custom_command: Runs a single command explicitly as written in the $URL field of the task list, including variable and command expansion. This should work the same as if you were runnig the command directly from the terminal. +# custom_command: Runs a single command explicitly as written in the $URL field of the task list, including variable and command expansion. This should work the same as if you were running the command directly from the terminal. # This command does not need a PLACEHOLDERTEXT field in the task list, so needs to be in this syntax: custom_command^^$COMMAND -# url: This is used to calculate a dynamic URL and the value to the $caluculated_url environmental variable, for use in other subsequent commands. - +# url: This is used to calculate a dynamic URL and the value to the $calculated_url environmental variable, for use in other subsequent commands. # Define paths rd_manifest="${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml" @@ -95,14 +97,43 @@ handle_latestghrelease() { local placeholder="$1" local url="$2" local suffix="$3" + echo "Fetching release data from: $url" local release_data=$(curl -s "$url") + echo "Release data fetched." local ghreleaseurl=$(echo "$release_data" | jq -r ".assets[] | select(.name | endswith(\"$suffix\")).browser_download_url") + + if [[ -z "$ghreleaseurl" ]]; then + echo "Error: No asset found with suffix $suffix" + exit 1 + fi + local ghreleasehash=$(curl -sL "$ghreleaseurl" | sha256sum | cut -d ' ' -f1) + echo "Replacing placeholder $placeholder with URL $ghreleaseurl and hash $ghreleasehash" /bin/sed -i 's^'"$placeholder"'^'"$ghreleaseurl"'^g' "$rd_manifest" /bin/sed -i 's^'"HASHFOR$placeholder"'^'"$ghreleasehash"'^g' "$rd_manifest" } +handle_latestghreleasesha() { + local placeholder="$1" + local url="$2" + local suffix="$3" + echo "Fetching release data from: $url" + local release_data=$(curl -s "$url") + echo "Release data fetched." + local ghreleaseurl=$(echo "$release_data" | jq -r ".assets[] | select(.name | endswith(\"$suffix\")).browser_download_url") + + if [[ -z "$ghreleaseurl" ]]; then + echo "Error: No asset found with suffix $suffix" + exit 1 + fi + + local ghreleasehash=$(curl -sL "$ghreleaseurl" | sha256sum | cut -d ' ' -f1) + + echo "Replacing placeholder $placeholder with hash $ghreleasehash" + /bin/sed -i 's^'"$placeholder"'^'"$ghreleasehash"'^g' "$rd_manifest" +} + handle_outside_file() { local placeholder="$1" local file_path="$2" @@ -148,6 +179,7 @@ while IFS="^" read -r action placeholder url branch || [[ -n "$action" ]]; do "latestcommit" ) handle_latestcommit "$placeholder" "$url" "$branch" ;; "latestghtag" ) handle_latestghtag "$placeholder" "$url" ;; "latestghrelease" ) handle_latestghrelease "$placeholder" "$url" "$branch" ;; + "latestghreleasesha" ) handle_latestghreleasesha "$placeholder" "$url" "$branch" ;; "outside_file" ) handle_outside_file "$placeholder" "$url" ;; "outside_env_var" ) handle_outside_env_var "$placeholder" "$url" ;; "custom_command" ) handle_custom_command "$url" ;; diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index 58e09394..2947663f 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -426,7 +426,7 @@ modules: sources: - type: archive url: RETRODECKPPSSPPURL - sha256: RETRODECKPPSSPPHASH + sha256: HASHRETRODECKPPSSPPURL # PPSSPP - END