Upgrade pre-build automation

This commit is contained in:
icenine451 2023-04-17 11:28:58 -04:00
parent 323ebef32c
commit 361b99e9a6
6 changed files with 66 additions and 37 deletions

View file

@ -42,7 +42,7 @@ jobs:
io.qt.qtwebengine.BaseApp/x86_64/6.3 \
org.freedesktop.Sdk.Extension.llvm13 \
org.freedesktop.Sdk.Extension.dotnet6/x86_64/21.08
/bin/bash ${GITHUB_WORKSPACE}/automation_tools/update_sha.sh # Run SHA placehold replacement script for dynamic archives
/bin/bash ${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh # Run pre-build automation tasks
- name: Build flatpak
run: |

View file

@ -42,7 +42,7 @@ jobs:
io.qt.qtwebengine.BaseApp/x86_64/6.3 \
org.freedesktop.Sdk.Extension.llvm13 \
org.freedesktop.Sdk.Extension.dotnet6/x86_64/21.08
sh ${GITHUB_WORKSPACE}/automation_tools/update_sha.sh # Run SHA placehold replacement script for dynamic archives
/bin/bash ${GITHUB_WORKSPACE}/automation_tools/pre_build_automation.sh # Run pre-build automation tasks
- name: Build flatpak
run: |

View file

@ -0,0 +1,4 @@
# The proper format for this file is
# ACTION^PLACEHOLDERTEXT^URL^REPO(Optional)
hash^DOOMSHAPLACEHOLDER^https://buildbot.libretro.com/assets/cores/DOOM/Doom%20%28Shareware%29.zip
hash^VITASHAPLACEHOLDER^https://github.com/Vita3K/Vita3K/releases/download/continuous/ubuntu-latest.zip

View file

@ -0,0 +1,58 @@
#!/bin/bash
# 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
# 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
# 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
rd_manifest=${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml
automation_task_list=${GITHUB_WORKSPACE}/automation_tools/automation_task_list.cfg
echo "Manifest location: $rd_manifest"
echo "Automation task list location: $automation_task_list"
echo
echo "Task list contents:"
cat "$automation_task_list"
echo
while IFS="^" read -r action placeholder url branch
do
if [[ ! $action == "#"* ]] && [[ ! -z "$action" ]]; then
if [[ "$action" == "hash" ]]; then
echo
echo "Placeholder text: $placeholder"
echo "URL to hash: $url"
echo
hash=$(curl -sL "$url" | sha256sum | cut -d ' ' -f1)
echo "Hash found: $hash"
/bin/sed -i 's^'"$placeholder"'^'"$hash"'^' $rd_manifest
elif [[ "$action" == "latestcommit" ]]; then
echo
echo "Placeholder text: $placeholder"
echo "Repo to get latest commit from: $url branch: $branch"
echo
commit=$(git ls-remote "$url" "$branch" | cut -f1)
echo "Commit found: $commit"
/bin/sed -i 's^'"$placeholder"'^'"$commit"'^' $rd_manifest
elif [[ "$action" == "latestappimage" ]]; then
echo
echo "Placeholder text: $placeholder"
echo "Repo to look for AppImage releases: $url"
echo
appimageurl=$(curl -s "$url" | grep browser_download_url | grep "\.AppImage\"" | cut -d : -f 2,3 | tr -d \" | sed -n 1p | tr -d ' ')
echo "AppImage URL found: $appimageurl"
/bin/sed -i 's^'"$placeholder"'^'"$appimageurl"'^' $rd_manifest
appimagehash=$(curl -sL "$appimageurl" | sha256sum | cut -d ' ' -f1)
echo "AppImage hash found: $appimagehash"
/bin/sed -i 's^'"HASHFOR$placeholder"'^'"$appimagehash"'^' $rd_manifest
fi
fi
done < "$automation_task_list"

View file

@ -1,4 +0,0 @@
# The proper format for this file is
# URL^PLACEHOLDERTEXT
https://buildbot.libretro.com/assets/cores/DOOM/Doom%20%28Shareware%29.zip^DOOMSHAPLACEHOLDER
https://github.com/Vita3K/Vita3K/releases/download/continuous/ubuntu-latest.zip^VITASHAPLACEHOLDER

View file

@ -1,29 +0,0 @@
#!/bin/bash
# For the file paths to work correctly, call this script with this command from the cloned repo folder root:
# sh automation_tools/update_sha.sh
rd_manifest=${GITHUB_WORKSPACE}/net.retrodeck.retrodeck.yml
sha_update_list=${GITHUB_WORKSPACE}/automation_tools/sha_update_list.cfg
echo "Manifest location: $rd_manifest"
echo "Hash update list location: $sha_update_list"
echo
echo "Update list contents:"
cat "$sha_update_list"
echo
while IFS="^" read -r url placeholder
do
if [[ ! "$url" == "#"* ]] && [[ ! -z "$url" ]]; then
echo
echo "Placeholder text: $placeholder"
echo "URL to hash: $url"
echo
hash=$(curl -sL "$url" | sha256sum | cut -d ' ' -f1)
echo "Hash found: $hash"
/bin/sed -i 's^'"$placeholder"'^'"$hash"'^' $rd_manifest
fi
done < "$sha_update_list"
echo "Done updating manifest hashes."