Skip to content

Commit 8aaa993

Browse files
authored
Merge pull request #1 from rsmb7z/patch-1
Create detect-release
2 parents eaef165 + ed6af28 commit 8aaa993

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

Diff for: .github/workflows/detect-release

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Detect IB API Release
2+
3+
on:
4+
schedule:
5+
- cron: "0 8 * * *"
6+
7+
workflow_dispatch:
8+
9+
jobs:
10+
detect-release:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Get Latest Version
18+
id: version
19+
run: |
20+
response=$(curl -s https://interactivebrokers.github.io)
21+
file_url=https://$(echo "$response" | grep -oP '(interactivebrokers.*twsapi_macunix.*zip)(?=.*Stable)')
22+
file_name=$(echo "$file_url" | grep -oP 'twsapi_macunix.*.zip')
23+
build_version=$(echo "$file_url" | grep -oP '(?<=twsapi_macunix.).*(?=.zip)')
24+
echo "file_url=$file_url" >> $GITHUB_OUTPUT
25+
echo "file_name=$file_name" >> $GITHUB_OUTPUT
26+
echo "build_version=$build_version" >> $GITHUB_OUTPUT
27+
28+
- name: Check if there is an update
29+
id: check-update
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
gh release list > /tmp/ibapi-releases
34+
if grep -qF '${{ steps.version.outputs.build_version }}' /tmp/ibapi-releases
35+
then
36+
echo "has_update=false" >> $GITHUB_OUTPUT
37+
else
38+
echo "has_update=true" >> $GITHUB_OUTPUT
39+
fi
40+
41+
- name: Download
42+
if: ${{ steps.check-update.outputs.has_update == 'true' }}
43+
run: |
44+
curl -sSL "${{ steps.version.outputs.file_url }}" --output "/tmp/${{ steps.version.outputs.file_name }}"
45+
46+
- name: Extract and Move
47+
if: ${{ steps.check-update.outputs.has_update == 'true' }}
48+
run: |
49+
unzip -o "/tmp/${{ steps.version.outputs.file_name }}" -d /tmp
50+
rsync -a /tmp/IBJts/source/pythonclient/ ./
51+
sed -i 's/version = "[^"]*"/version = "'"${{ steps.version.outputs.build_version }}"'"/' pyproject.toml
52+
53+
- name: Create release
54+
if: ${{ steps.check-update.outputs.has_update == 'true' }}
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
run: |
58+
gh release create 'ibapi-stable@${{ steps.version.outputs.build_version }}' \
59+
-t 'IB API Stable ${{ steps.version.outputs.build_version }}' \
60+
-n 'IB API Stable ${{ steps.version.outputs.build_version }} release files'
61+
62+
- name: Create PR
63+
if: ${{ steps.check-update.outputs.has_update == 'true' }}
64+
env:
65+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: |
67+
t_branch='update-stable-to-${{ steps.version.outputs.build_version }}'
68+
git config user.name github-actions
69+
git config user.email [email protected]
70+
git pull
71+
git checkout -b "$t_branch" origin/main
72+
git add -A
73+
git commit -m 'Update Stable to `${{ steps.version.outputs.build_version }}`'
74+
git push --set-upstream origin "$t_branch"
75+
gh pr create --base main --fill

0 commit comments

Comments
 (0)