From 5976e478ab218d2e2f6bf2808fb84182f037a04e Mon Sep 17 00:00:00 2001 From: Lord Friky <24846044+lordfriky@users.noreply.github.com> Date: Thu, 18 May 2023 00:14:19 -0600 Subject: [PATCH] Move the updating payload process to its own script and fix the action Also, Atmosphere was updated in the process --- .github/workflows/update-payloads.yml | 61 ++----------------- extras/update-payloads.sh | 71 ++++++++++++++++++++++ payloads/{ams-1.5.3.bin => ams-1.5.4.bin} | Bin payloads/payloads.json | 6 +- 4 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 extras/update-payloads.sh rename payloads/{ams-1.5.3.bin => ams-1.5.4.bin} (100%) diff --git a/.github/workflows/update-payloads.yml b/.github/workflows/update-payloads.yml index f8d2735..00bb34b 100644 --- a/.github/workflows/update-payloads.yml +++ b/.github/workflows/update-payloads.yml @@ -13,70 +13,21 @@ jobs: - name: Install jq run: sudo apt install -y jq - - name: Determine actual and latest versions of all payloads - run: | - # To-do: Maybe improve this process? - - # Actual versions - echo "AMS_VERSION=$(sed -n 5p payloads/payloads.json | cut -d '"' -f4)" >> $GITHUB_ENV - echo "HKT_VERSION=$(sed -n 10p payloads/payloads.json | cut -d '"' -f4)" >> $GITHUB_ENV - echo "TEX_VERSION=$(sed -n 15p payloads/payloads.json | cut -d '"' -f4)" >> $GITHUB_ENV - - # Latest versions - echo "AMS_LATEST=$(curl -s https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases/latest | grep tag_name | cut -d '"' -f4)" >> $GITHUB_ENV - echo "HKT_LATEST=$(curl -s https://api.github.com/repos/CTCaer/hekate/releases/latest | grep tag_name | cut -d '"' -f4)" >> $GITHUB_ENV - echo "TEX_LATEST=$(curl -s https://api.github.com/repos/suchmememanyskill/TegraExplorer/releases/latest | grep tag_name | cut -d '"' -f4)" >> $GITHUB_ENV - - name: Update required payloads - run: | - mkdir payloads/temp && cd payloads/temp - UPDATE=false - - if [[ "$AMS_VERSION" -ne "AMS_LATEST" ]] - then - UPDATE=true - rm ../ams-*.bin - wget $(curl -s https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases/latest | grep browser_download_url | grep fusee.bin | cut -d '"' -f4) - mv fusee.bin ../ams-$AMS_LATEST.bin - - jq --arg version "$AMS_LATEST" '.payloads[0].version |= $version' ../payloads.json | jq --arg path "payloads/ams-$AMS_LATEST.bin" '.payloads[0].path |= $path' > ../payloads_temp.json - mv ../payloads_temp.json ../payloads.json - fi - - if [[ "$HKT_VERSION" -ne "HKT_LATEST" ]] - then - UPDATE=true - rm ../hekate-*.bin - wget $(curl -s https://api.github.com/repos/CTCaer/hekate/releases/latest | grep browser_download_url | grep "hekate_ctcaer_.*\.zip" | cut -d '"' -f4) - unzip hekate_ctcaer_*.zip - mv hekate_ctcaer_*.bin ../hekate-$HKT_LATEST.bin - - jq --arg version "$HKT_LATEST" '.payloads[1].version |= $version' ../payloads.json | jq --arg path "payloads/hekate-$HKT_LATEST.bin" '.payloads[1].path |= $path' > ../payloads_temp.json - mv ../payloads_temp.json ../payloads.json - fi - - if [[ "$TEX_VERSION" -ne "$TEX_LATEST" ]] - then - UPDATE=true - rm ../tegraexplorer-*.bin - wget $(curl -s https://api.github.com/repos/suchmememanyskill/TegraExplorer/releases/latest | grep browser_download_url | grep TegraExplorer.bin | cut -d '"' -f4) - mv TegraExplorer.bin ../tegraexplorer-$TEX_LATEST.bin - - jq --arg version "$TEX_LATEST" '.payloads[2].version |= $version' ../payloads.json | jq --arg path "payloads/hekate-$TEX_LATEST.bin" '.payloads[2].path |= $path' > ../payloads_temp.json - mv ../payloads_temp.json ../payloads.json - fi - - echo "UPDATE=$UPDATE" >> $GITHUB_ENV - cd ../.. && rm -r payloads/temp + - name: Update payloads + run: sh extras/update-payloads.sh - name: Commit changes if necessary run: | - if [[ "$UPDATE" -eq true ]] + if [ "$UPDATE" == true ]; then + echo 'Commiting changes!' git config --global user.name 'GitHub Actions' git config --global user.email 'github-actions@users.noreply.github.com' git add --all git commit -am ":robot: Payloads updated automatically" git push + else + echo "Commit not needed." fi diff --git a/extras/update-payloads.sh b/extras/update-payloads.sh new file mode 100644 index 0000000..ba039f5 --- /dev/null +++ b/extras/update-payloads.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# To-do: Use jq for everything instead of sed, grep and cut + +# Actual versions +AMS_VERSION=$(sed -n 5p payloads/payloads.json | cut -d '"' -f4) +HKT_VERSION=$(sed -n 10p payloads/payloads.json | cut -d '"' -f4) +TEX_VERSION=$(sed -n 15p payloads/payloads.json | cut -d '"' -f4) + +# Latest versions +AMS_LATEST=$(curl -s https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases | jq '.[0]' | grep tag_name | cut -d '"' -f4) +HKT_LATEST=$(curl -s https://api.github.com/repos/CTCaer/hekate/releases | jq '.[0]' | grep tag_name | cut -d '"' -f4) +TEX_LATEST=$(curl -s https://api.github.com/repos/suchmememanyskill/TegraExplorer/releases | jq '.[0]' | grep tag_name | cut -d '"' -f4) + +if [ -d payloads/temp ]; +then + echo "Leftover temp directory detected. Deleting it..." + rm -r payloads/temp +fi + +mkdir payloads/temp && cd payloads/temp +UPDATE=false + +if [[ "$AMS_VERSION" != "$AMS_LATEST" ]]; +then + echo "Newest Atmosphere version detected ($AMS_LATEST). Updating..." + UPDATE=true + rm ../ams-*.bin + wget $(curl -s https://api.github.com/repos/Atmosphere-NX/Atmosphere/releases | jq '.[0]' | grep browser_download_url | grep fusee.bin | cut -d '"' -f4) + mv fusee.bin ../ams-$AMS_LATEST.bin + + jq --arg version "$AMS_LATEST" '.payloads[0].version |= $version' ../payloads.json | jq --arg path "payloads/ams-$AMS_LATEST.bin" '.payloads[0].path |= $path' > ../payloads_temp.json + mv ../payloads_temp.json ../payloads.json + echo "Atmosphere successfully updated! " +fi + +if [[ "$HKT_VERSION" != "$HKT_LATEST" ]]; +then + echo "Newest Hekate version detected ($HKT_LATEST). Updating..." + UPDATE=true + rm ../hekate-*.bin + wget $(curl -s https://api.github.com/repos/CTCaer/hekate/releases | jq '.[0]' | grep browser_download_url | grep "hekate_ctcaer_.*\.zip" | cut -d '"' -f4) + unzip hekate_ctcaer_*.zip + mv hekate_ctcaer_*.bin ../hekate-$HKT_LATEST.bin + + jq --arg version "$HKT_LATEST" '.payloads[1].version |= $version' ../payloads.json | jq --arg path "payloads/hekate-$HKT_LATEST.bin" '.payloads[1].path |= $path' > ../payloads_temp.json + mv ../payloads_temp.json ../payloads.json + echo "Hekate successfully updated!" +fi + +if [[ "$TEX_VERSION" != "$TEX_LATEST" ]]; +then + echo "Newset TegraExplorer version detected ($TEX_LATEST). Updating..." + UPDATE=true + rm ../tegraexplorer-*.bin + wget $(curl -s https://api.github.com/repos/suchmememanyskill/TegraExplorer/releases | jq '.[0]' | grep browser_download_url | grep TegraExplorer.bin | cut -d '"' -f4) + mv TegraExplorer.bin ../tegraexplorer-$TEX_LATEST.bin + + jq --arg version "$TEX_LATEST" '.payloads[2].version |= $version' ../payloads.json | jq --arg path "payloads/hekate-$TEX_LATEST.bin" '.payloads[2].path |= $path' > ../payloads_temp.json + mv ../payloads_temp.json ../payloads.json + echo 'TegraExplorer successfully updated!' +fi + +cd ../.. && rm -r payloads/temp + +if [[ -n "$GITHUB_ACTIONS" ]]; +then + echo "UPDATE=$UPDATE" >> $GITHUB_ENV +fi + +echo "Update complete." diff --git a/payloads/ams-1.5.3.bin b/payloads/ams-1.5.4.bin similarity index 100% rename from payloads/ams-1.5.3.bin rename to payloads/ams-1.5.4.bin diff --git a/payloads/payloads.json b/payloads/payloads.json index 6a9660c..c7e35f1 100644 --- a/payloads/payloads.json +++ b/payloads/payloads.json @@ -2,8 +2,8 @@ "payloads": [ { "name": "Atmosphère", - "version": "1.5.3", - "path": "payloads/ams-1.5.3.bin" + "version": "1.5.4", + "path": "payloads/ams-1.5.4.bin" }, { "name": "Hekate", @@ -21,4 +21,4 @@ "path": "uploaded" } ] -} \ No newline at end of file +}