Update #96
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update | |
on: | |
schedule: | |
- cron: "0 12 * * *" | |
env: | |
URL: https://download.panic.com/playdate_sdk/Windows/PlaydateSDK-latest.exe | |
jobs: | |
update: | |
name: Update Latest | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v3 | |
- name: check redirect target | |
id: check | |
run: | | |
trim() { | |
local trimmed="$1" | |
# Strip leading space. | |
trimmed="${trimmed## }" | |
# Strip trailing space. | |
trimmed="${trimmed%% }" | |
echo "$trimmed" | |
} | |
LATEST_TARGET=$(cat .github/latest-url.txt) | |
LATEST_TARGET=$(trim "$LATEST_TARGET") | |
echo " prev: $LATEST_TARGET" | |
ACTUAL_TARGET=$(curl -X HEAD -w "%{url_effective}" -I -L -s -S $URL -o /dev/null) | |
ACTUAL_TARGET=$(trim "$ACTUAL_TARGET") | |
echo "actual: $ACTUAL_TARGET" | |
# save: | |
echo "$ACTUAL_TARGET" > .github/latest-url.txt | |
[ "$ACTUAL_TARGET" == "$LATEST_TARGET" ] && echo "update not needed" | |
[ "$ACTUAL_TARGET" == "$LATEST_TARGET" ] || (echo "changed=true" >> $GITHUB_OUTPUT) | |
- name: update | |
id: update | |
if: steps.check.outputs.changed | |
run: | | |
echo "download $URL" | |
curl -L -sS --show-error --fail "$URL" -o ./sdk | |
NEW_HASH=$(shasum -ba 256 ./sdk) | |
echo "new hash: $NEW_HASH" | |
rm -rf ./sdk | |
# save hash: | |
ruby .github/workflows/update.rb "winget-latest/Panic.PlaydateSDK.installer.yaml" $NEW_HASH | |
echo "saved" | |
- name: create PR | |
if: steps.check.outputs.changed | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
add-paths: | | |
winget-latest/Panic.PlaydateSDK.installer.yaml | |
.github/latest-url.txt | |
commit-message: "update to latest SDK (win)" | |
title: "Update to latest SDK" | |
labels: win | |
body: "Updated hash of new SDK installer for windows." | |
branch: update-hash | |
branch-suffix: short-commit-hash | |
delete-branch: true | |
#TODO: add @rtsuk | |
assignees: boozook | |
reviewers: boozook |