Auto-update casks on new releases #39307
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: Auto-update casks on new releases | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 * * * *" | |
jobs: | |
scheduled: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out this repo | |
uses: actions/checkout@v4 | |
- name: Fetch latest versions | |
run: |- | |
MILLISECONDS=$(date '+%s')$(($RANDOM % 1000)) | |
curl "https://download2.interactivebrokers.com/installers/tws/latest-standalone/version.json?_=$MILLISECONDS&callback=twslatest_callback" | jq -R 'capture("\\((?<x>.*)\\)[^)]*$").x | fromjson | .buildVersion' > latest | |
curl "https://download2.interactivebrokers.com/installers/tws/stable-standalone/version.json?_=$MILLISECONDS&callback=twsstable_callback" | jq -R 'capture("\\((?<x>.*)\\)[^)]*$").x | fromjson | .buildVersion' > stable | |
curl "https://download2.interactivebrokers.com/installers/tws/beta/version.json?_=$MILLISECONDS&callback=twsbetaupdatable_callback" | jq -R 'capture("\\((?<x>.*)\\)[^)]*$").x | fromjson | .buildVersion' > beta | |
curl "https://download2.interactivebrokers.com/installers/ntws/latest-standalone/version.json?_=$MILLISECONDS&callback=ntwslatest_callback" | jq -R 'capture("\\((?<x>.*)\\)[^)]*$").x | fromjson | .buildVersion' > ntws_latest | |
- name: Update Casks | |
run: |- | |
sed -i "s/version .*/version $(cat latest)/g" Casks/trader-workstation-latest.rb | |
sed -i "s/version .*/version $(cat stable)/g" Casks/trader-workstation-stable.rb | |
sed -i "s/version .*/version $(cat beta)/g" Casks/trader-workstation-beta.rb | |
sed -i "s/version .*/version $(cat ntws_latest)/g" Casks/ibkr-desktop-latest.rb | |
if [[ `git status --porcelain` ]]; then | |
echo "New versions detected" | |
echo " Latest: $(cat latest)" | |
echo " Stable: $(cat stable)" | |
echo " Beta: $(cat beta)" | |
echo " IBKR Desktop: $(cat ntws_latest)" | |
rm latest | |
rm stable | |
rm beta | |
rm ntws_latest | |
git config user.name "Auto Updater" | |
git config user.email "[email protected]" | |
git add -A | |
timestamp=$(date -u) | |
git commit -m "Auto-update TWS Casks: ${timestamp}" || exit 0 | |
git push | |
fi |