Merge branch 'cooker-0.8.0b' into feat/helper-files-generator

This commit is contained in:
XargonWan 2024-01-25 10:43:18 +01:00
commit 884d2bda08
3 changed files with 53 additions and 9 deletions

View file

@ -11,5 +11,5 @@ hash^RANIGHTLYCORESPLACEHOLDER^https://buildbot.libretro.com/nightly/linux/x86_6
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"
latestcommit^UNIVERSALDYNAMICINPUTCOMMITPLACEHOLDER^https://github.com/Venomalia/UniversalDynamicInput^main
outside_info^VERSIONPLACEHOLDER^${GITHUB_WORKSPACE}/buildid
outside_file^VERSIONPLACEHOLDER^${GITHUB_WORKSPACE}/buildid
branch^THISBRANCH

View file

@ -3,15 +3,21 @@
# For the file paths to work correctly, call this script with this command from the cloned repo folder root:
# 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.
# 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.
# Needs the URL of the repo and the branch to find the latest commit from, in this line format: latestcommit^PLACEHOLDERTEXT^url^branch
# latestappimage: Finds the download URL and SHA256 hash of the latest AppImage release from a git repo
# latestappimage: Finds the download URL and SHA256 hash of the latest AppImage release from a git repo.
# Needs the API URL of the repo, in this line format: latestappimage^PLACEHOLDERTEXT^https://api.github.com/repos/<owner-name>/<repo-name>/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
# 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.
# 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.
rd_manifest=${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml
automation_task_list=${GITHUB_WORKSPACE}/automation_tools/automation_task_list.cfg
@ -35,13 +41,17 @@ echo
while IFS="^" read -r action placeholder url branch
do
if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then
if [[ "$action" == "branch" ]]; then
case "$action" in
"branch" )
echo
echo "Placeholder text: $placeholder"
echo "Current branch:" "$current_branch"
echo
/bin/sed -i 's^'"$placeholder"'^'"$current_branch"'^g' $rd_manifest
elif [[ "$action" == "hash" ]]; then
;;
"hash" )
echo
echo "Placeholder text: $placeholder"
calculated_url=$(eval echo "$url") # in case the url has to be calculated from an expression
@ -50,7 +60,9 @@ do
hash=$(curl -sL "$calculated_url" | sha256sum | cut -d ' ' -f1)
echo "Hash found: $hash"
/bin/sed -i 's^'"$placeholder"'^'"$hash"'^' $rd_manifest
elif [[ "$action" == "latestcommit" ]]; then
;;
"latestcommit" )
echo
echo "Placeholder text: $placeholder"
echo "Repo to get latest commit from: $url branch: $branch"
@ -58,7 +70,9 @@ do
commit=$(git ls-remote "$url" "$branch" | cut -f1)
echo "Commit found: $commit"
/bin/sed -i 's^'"$placeholder"'^'"$commit"'^' $rd_manifest
elif [[ "$action" == "latestappimage" ]]; then
;;
"latestappimage" )
echo
echo "Placeholder text: $placeholder"
echo "Repo to look for AppImage releases: $url"
@ -69,7 +83,9 @@ do
appimagehash=$(curl -sL "$appimageurl" | sha256sum | cut -d ' ' -f1)
echo "AppImage hash found: $appimagehash"
/bin/sed -i 's^'"HASHFOR$placeholder"'^'"$appimagehash"'^' $rd_manifest
elif [[ "$action" == "outside_info" ]]; then
;;
"outside_file" )
if [[ "$url" = \$* ]]; then # If value is a reference to a variable name
eval url="$url"
fi
@ -78,7 +94,27 @@ do
echo "Information being injected: $(cat $url)"
echo
/bin/sed -i 's^'"$placeholder"'^'"$(cat $url)"'^' $rd_manifest
elif [[ "$action" == "url" ]]; then
;;
"outside_env_var" )
if [[ "$url" = \$* ]]; then # If value is a reference to a variable name
eval url="$url"
fi
echo
echo "Placeholder text: $placeholder"
echo "Information being injected: $(echo $url)"
echo
/bin/sed -i 's^'"$placeholder"'^'"$(echo $url)"'^' $rd_manifest
;;
"custom_command" )
echo
echo "Command to run: $url"
echo
eval "$url"
;;
"url" )
# this is used to calculate a dynamic url
echo
echo "Placeholder text: $placeholder"
@ -86,6 +122,8 @@ do
echo "Information being injected: $calculated_url"
echo
/bin/sed -i 's^'"$placeholder"'^'"$calculated_url"'^' $rd_manifest
fi
;;
esac
fi
done < "$automation_task_list"

View file

@ -29,7 +29,13 @@ gba
gbc
genesis
mastersystem
n64
nds
nes
ngp
ngpc
sega32x
sega32xjp
sega32xna
snes
snesna