Detect, Test and Publish IB Gateway/TWS Releases #440
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: Detect, Test and Publish IB Gateway/TWS Releases | |
on: | |
schedule: | |
- cron: "0 8 * * *" # 8AM UTC daily | |
workflow_dispatch: | |
jobs: | |
check-new-version: | |
name: Check for new IBKR stable/latest versions | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
channel: ["stable", "latest"] | |
outputs: | |
build_version: ${{ steps.version.outputs.build_version }} | |
has_update: ${{ steps.check-update.outputs.has_update }} | |
channel: ${{ matrix.channel }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Latest IB Gateway Version | |
id: version | |
run: | | |
res=$(curl -s https://download2.interactivebrokers.com/installers/ibgateway/${{ matrix.channel }}-standalone/version.json) | |
build_version=$(grep -oP '(?<=buildVersion":")[^"]+' <<< "$res") | |
echo "build_version=$build_version" >> $GITHUB_OUTPUT | |
- name: Check Latest Version against Releases | |
id: check-update | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
if gh release list | grep -qF '${{ steps.version.outputs.build_version }}-${{ matrix.channel }}'; then | |
echo "has_update=false" >> $GITHUB_OUTPUT | |
else | |
echo "has_update=true" >> $GITHUB_OUTPUT | |
fi | |
test-and-commit: | |
name: Test version and commit | |
runs-on: ubuntu-latest | |
needs: check-new-version | |
if: needs.check-new-version.outputs.has_update == 'true' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download IB Gateway | |
run: | | |
download_url='https://download2.interactivebrokers.com/installers/ibgateway/${{ needs.check-new-version.outputs.channel }}-standalone/ibgateway-${{ needs.check-new-version.outputs.channel }}-standalone-linux-x64.sh' | |
dest='ibgateway-${{ needs.check-new-version.outputs.build_version }}-standalone-linux-x64.sh' | |
curl -sSL "$download_url" --output "$dest" | |
sha256sum "$dest" > "${dest}.sha256" | |
- name: Create release | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create '${{ needs.check-new-version.outputs.build_version }}-${{ needs.check-new-version.outputs.channel }}' \ | |
-t 'ibgateway ${{ needs.check-new-version.outputs.build_version }}-${{ needs.check-new-version.outputs.channel }}' \ | |
ibgateway-* | |
- name: Update ${{ needs.check-new-version.outputs.channel }}/ | |
run: ./build.sh ${{ needs.check-new-version.outputs.channel }} ${{ needs.check-new-version.outputs.build_version }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Set up pdm | |
run: curl -sSL https://pdm-project.org/install-pdm.py | python3 - | |
- name: Update and sync dependencies | |
run: pdm update -u | |
- name: Build Docker image | |
run: | | |
docker build ${{ needs.check-new-version.outputs.channel }} -t image | |
- name: Test ${{ needs.check-new-version.outputs.channel }} | |
run: ./start-docker.sh && pdm run pytest | |
env: | |
USERNAME: ${{ secrets.USERNAME }} | |
PASSWORD: ${{ secrets.PASSWORD }} | |
- name: Commit with appropriate docker tag | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Update ${{ needs.check-new-version.outputs.channel }} to ${{ needs.check-new-version.outputs.build_version }} | |
# By itself, will not trigger docker.yml action due to Github restrictions | |
tagging_message: docker-${{needs.check-new-version.outputs.build_version}}-${{needs.check-new-version.outputs.channel}} | |
build: | |
name: Trigger Docker Build Action | |
needs: test-and-commit | |
uses: ./.github/workflows/docker.yml |