Skip to content

Detect IB Gateway Releases #826

Detect IB Gateway Releases

Detect IB Gateway Releases #826

name: Detect IB Gateway Releases
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
defaults:
run:
shell: "bash -Eeuo pipefail -x {0}"
jobs:
detect-release:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
channel: ["stable", "latest"]
steps:
- uses: actions/checkout@v3
- name: Get Latest Version
id: version
run: |
res=$(curl -s https://download2.interactivebrokers.com/installers/tws/${{ matrix.channel }}-standalone/version.json | sed 's/tws${{ matrix.channel }}_callback(//g;s/);//g')
build_version=$(jq -r '.buildVersion' <<< "$res")
#build_dateTime=$(jq -r '.buildDateTime' <<< "$res")
echo "build_version=$build_version" >> $GITHUB_OUTPUT
#echo "build_dateTime=$build_dateTime" >> $GITHUB_OUTPUT
- name: Check if there is an update
id: check-update
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release list > /tmp/ibgateway-releases
if grep -qF '${{ steps.version.outputs.build_version }}' /tmp/ibgateway-releases
then
echo "has_update=false" >> $GITHUB_OUTPUT
else
echo "has_update=true" >> $GITHUB_OUTPUT
fi
- name: Download
if: ${{ steps.check-update.outputs.has_update == 'true' }}
run: |
download_url='https://download2.interactivebrokers.com/installers/ibgateway/${{ matrix.channel }}-standalone/ibgateway-${{ matrix.channel }}-standalone-linux-x64.sh'
dest='ibgateway-${{ steps.version.outputs.build_version }}-standalone-linux-x64.sh'
curl -sSL "$download_url" --output "$dest"
sha256sum "$dest" > "${dest}.sha256"
- name: Create release
if: ${{ steps.check-update.outputs.has_update == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create 'ibgateway-${{ matrix.channel }}@${{ steps.version.outputs.build_version }}' \
-t 'IB Gateway ${{ matrix.channel }} ${{ steps.version.outputs.build_version }}' \
-n 'IB Gateway ${{ matrix.channel }} ${{ steps.version.outputs.build_version }} release files' \
ibgateway-*
- name: Update ${{ matrix.channel }}
if: ${{ steps.check-update.outputs.has_update == 'true' }}
run: ./update.sh ${{ matrix.channel }} ${{ steps.version.outputs.build_version }}
- name: Create PR
if: ${{ steps.check-update.outputs.has_update == 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
t_branch='update-${{ matrix.channel }}-to-${{ steps.version.outputs.build_version }}'
git config user.name github-actions
git config user.email github-actions@github.com
git pull
git checkout -b "$t_branch" origin/master
git add '${{ matrix.channel }}'
git commit -m 'Update `${{ matrix.channel }}` to `${{ steps.version.outputs.build_version }}`'
git push --set-upstream origin "$t_branch"
gh pr create --base master --fill