Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add work-in-progress auto-update script #2

Merged
merged 8 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: update casks

on:
schedule:
- cron: '0 6 * * 6'
workflow_dispatch:

jobs:
test-bot:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Update Casks
run: |
./Scripts/update.sh
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
title: 'Update Casks'
commit-message: 'Update Casks'
2 changes: 2 additions & 0 deletions Scripts/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
disable=SC2292
disable=SC2312
34 changes: 34 additions & 0 deletions Scripts/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh

LATEST_VERSION=$(gh api repos/SteamRE/DepotDownloader/releases/latest | jq -r ".name" | sed 's/DepotDownloader[_ ]//')
CURRENT_VERSION=$(grep 'version "' Casks/depotdownloader.rb | cut -d '"' -f 2)

if [ "${LATEST_VERSION}" = "${CURRENT_VERSION}" ]
then
echo "DepotDownloader Cask is up to date."
exit 0
fi

if [ "$(uname)" = "Darwin" ]
then
SED_INLINE="sed -i .tmp"
else
SED_INLINE="sed -i"
fi

update_for_arch() {
BREW_ARCH=$1
FILE_ARCH=$2

FILE_SHA_256=$(curl -fSsL -o - "https://github.com/SteamRE/DepotDownloader/releases/download/DepotDownloader_${LATEST_VERSION}/DepotDownloader-macos-${FILE_ARCH}.zip" | shasum -a 256 | awk '{print $1}')
${SED_INLINE} "s/${BREW_ARCH}:\([ \t]*\)\"[0-9a-f]*\"/${BREW_ARCH}:\1\"${FILE_SHA_256}\"/g" Casks/depotdownloader.rb
}

${SED_INLINE} "s/version \"${CURRENT_VERSION}\"/version \"${LATEST_VERSION}\"/" Casks/depotdownloader.rb
update_for_arch arm arm64
update_for_arch intel x64

if [ "$(uname)" = "Darwin" ]
then
rm Casks/*.tmp
fi
Loading