-
Notifications
You must be signed in to change notification settings - Fork 53
126 lines (110 loc) · 5.08 KB
/
detect-releases.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Detect IB Gateway Releases
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:
defaults:
run:
shell: "bash -Eeuo pipefail -x {0}"
jobs:
detect-release:
runs-on: ubuntu-latest
outputs:
update: ${{ steps.check-update.outputs.has_update }}
channel: ${{ matrix.channel }}
strategy:
fail-fast: true
matrix:
channel: ["stable", "latest"]
steps:
- uses: actions/checkout@v4
- 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 '${{ matrix.channel }}@${{ 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: Update README
if: ${{ steps.check-update.outputs.has_update == 'true' }}
run: |
# get stable and latest versions
export _stable_dockerfile='stable/Dockerfile'
export _latest_dockerfile='latest/Dockerfile'
if [ ${{ matrix.channel }} = 'latest' ]; then
# set latest
export LATEST_VERSION=${{ steps.version.outputs.build_version }}
export LATEST_MINOR=$(echo $LATEST_VERSION | cut -d '.' -f1,2)
# set stable
export STABLE_VERSION=$(grep 'ENV IB_GATEWAY_VERSION=' $_stable_dockerfile | head -1 | cut -d '=' -f2)
export STABLE_MINOR=$(echo $STABLE_VERSION| cut -d '.' -f1,2)
elif [ ${{ matrix.channel }} = 'stable' ]; then
# set STABLE
export STABLE_VERSION=${{ steps.version.outputs.build_version }}
export STABLE_MINOR=$(echo $STABLE_VERSION | cut -d '.' -f1,2)
# set LATEST
export LATEST_VERSION=$(grep 'ENV IB_GATEWAY_VERSION=' $_latest_dockerfile | head -1 | cut -d '=' -f2)
export LATEST_MINOR=$(echo $LATEST_VERSION| cut -d '.' -f1,2)
else
echo "invalid channel: ${{ matrix.channel }}"
exit 1
fi
# IBC
export IBC_VERSION="$(grep 'ENV IBC_VERSION' Dockerfile.template|cut -d '=' -f 2)"
# show in log
echo "$LATEST_VERSION,$LATEST_MINOR,$STABLE_VERSION,$STABLE_MINOR,$IBC_VERSION"
# replace variables
envsubst '$LATEST_VERSION,$LATEST_MINOR,$STABLE_VERSION,$STABLE_MINOR,$IBC_VERSION' < template_README.md > README.md
- 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 [email protected]
git pull
git checkout -b "$t_branch" origin/master
git add '${{ matrix.channel }}' README.md
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
build:
name: Call build workflow
needs: detect-release
if: needs.detect-release.outputs.update == 'true'
uses: gnzsnz/ib-gateway-docker/.github/workflows/build.yml@master
with:
channel: ${{ needs.detect-release.outputs.channel }}