Skip to content

Commit 0528b56

Browse files
committed
Try a different approach for generate bindings
1 parent e9a6969 commit 0528b56

File tree

1 file changed

+83
-34
lines changed

1 file changed

+83
-34
lines changed
Lines changed: 83 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,106 @@
1-
name: Generate Bindings
1+
name: Auto update AWS LibAwsCommon package
2+
23
on:
4+
schedule:
5+
- cron: '0 * * * *' # Run every hour
36
workflow_dispatch:
4-
pull_request:
5-
branches: [main]
6-
paths:
7-
- .github/workflows/generate_bindings.yml
8-
- gen/Project.toml
9-
10-
concurrency:
11-
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
12-
cancel-in-progress: true
137

148
permissions:
159
contents: write
10+
pull-requests: write
11+
12+
env:
13+
LIBAWS_REPO: "JuliaServices/LibAwsCommon.jl"
14+
JLL_REPO: "JuliaBinaryWrappers/aws_c_common_jll.jl"
15+
LIBRARY_NAME: "aws_c_common"
16+
JLL_NAME: "aws_c_common_jll"
1617

1718
jobs:
18-
generate-bindings:
19-
name: Generate bindings
20-
runs-on: ubuntu-22.04
21-
timeout-minutes: 20
19+
update-awscommon-package:
20+
runs-on: ubuntu-latest
21+
2222
steps:
23-
- name: Checkout PR branch
23+
- name: Checkout repository
2424
uses: actions/checkout@v4
2525
with:
26-
ref: ${{ github.event.pull_request.head.ref }}
27-
repository: ${{ github.event.pull_request.head.repo.full_name }}
28-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
26+
repository: ${{ env.LIBAWS_REPO }}
27+
ref: main
28+
token: ${{ secrets.GITHUB_TOKEN }}
2929

30-
- uses: julia-actions/setup-julia@v1
30+
- name: Checkout BinaryWrapper repository
31+
uses: actions/checkout@v4
3132
with:
32-
version: "1.10.2"
33+
repository: ${{ env.JLL_REPO }}
34+
path: jll
35+
ref: main
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Parse current JLL version
39+
run: |
40+
RAW_JLL_VERSION=$(grep -oP -m 1 '(?<=version = ")[^"]+' jll/Project.toml)
41+
JLL_VERSION=$(echo "$RAW_JLL_VERSION" | sed 's/+[0-9]*//')
42+
echo "JLL_VERSION=${JLL_VERSION}" >> $GITHUB_ENV
43+
44+
- name: Parse Project.toml compat version
45+
run: |
46+
COMPAT_SECTION=$(awk '/^\[compat\]/ {flag=1; next} /^\[/{flag=0} flag' Project.toml)
47+
PROJECT_VERSION=$(echo "$COMPAT_SECTION" | grep -oP "(?<=${{ env.JLL_NAME }} = \")[^\"]+" | sed 's/^=//')
48+
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV
49+
50+
- name: Check for version updates
51+
id: check_version
52+
run: |
53+
if [[ "$JLL_VERSION" != "$PROJECT_VERSION" ]]; then
54+
echo "New version found: $JLL_VERSION (was $PROJECT_VERSION)"
55+
echo "update_needed=true" >> $GITHUB_ENV
56+
else
57+
echo "No update needed."
58+
exit 0
59+
fi
60+
61+
- name: Update Project.toml Versions
62+
if: env.update_needed == 'true'
63+
run: |
64+
sed -i "s/${{ env.JLL_NAME }} = \"=$PROJECT_VERSION\"/${{ env.JLL_NAME }} = \"=$JLL_VERSION\"/" Project.toml
65+
sed -i "s/${{ env.JLL_NAME }} = \"=$PROJECT_VERSION\"/${{ env.JLL_NAME }} = \"=$JLL_VERSION\"/" gen/Project.toml
66+
67+
CURRENT_LIBAWS_VERSION=$(grep -oP -m 1 '(?<=version = ")[^"]+' Project.toml)
68+
PATCH=$(echo $CURRENT_LIBAWS_VERSION | awk -F. '{print $3+1}')
69+
NEW_LIBAWS_VERSION=$(echo $CURRENT_LIBAWS_VERSION | awk -F. '{print $1"."$2"."'"$PATCH"'}')
70+
sed -i "s/version = \"$CURRENT_LIBAWS_VERSION\"/version = \"$NEW_LIBAWS_VERSION\"/" Project.toml
3371
3472
- uses: julia-actions/cache@v2
3573

3674
- name: Run the generator
75+
if: env.update_needed == 'true'
3776
run: ./gen/generate.sh
3877

39-
- name: Check for changes
40-
id: check_diff
78+
- name: Check for Changes in Bindings
79+
if: env.update_needed == 'true'
80+
id: check_bindings
4181
run: |
4282
if git diff --quiet; then
43-
echo "No changes detected."
44-
echo "changed=false" >> $GITHUB_ENV
83+
echo "No bindings changes detected."
84+
echo "bindings_changed=false" >> $GITHUB_ENV
4585
else
46-
echo "Changes detected."
47-
echo "changed=true" >> $GITHUB_ENV
86+
echo "Bindings changed."
87+
echo "bindings_changed=true" >> $GITHUB_ENV
4888
fi
4989
50-
- name: Commit and Push Changes
51-
if: env.changed == 'true'
52-
run: |
53-
git config --global user.name "github-actions[bot]"
54-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
55-
git add .
56-
git commit -m "Regenerate bindings"
57-
git push origin ${{ github.event.pull_request.head.ref }}
90+
- name: Commit and Open PR
91+
if: env.bindings_changed == 'true'
92+
uses: peter-evans/create-pull-request@v6
93+
with:
94+
branch: update-${{ env.JLL_NAME }}-${{ env.JLL_VERSION }}
95+
commit-message: "Update ${{ env.JLL_NAME }} to version ${{ env.JLL_VERSION }}"
96+
title: "Update ${{ env.JLL_NAME }} to version ${{ env.JLL_VERSION }}"
97+
body: |
98+
This PR updates the JLL dependency and regenerates bindings automatically.
99+
100+
- Updated **${{ env.JLL_NAME }}** to version **${{ env.JLL_VERSION }}**
101+
- Updated **${{ env.LIBAWS_REPO }}** version number
102+
- **Bindings regeneration:**
103+
- ${{ env.bindings_changed == 'true' && '✅ Updated bindings' || '⚠️ No bindings changes detected' }}
104+
105+
reviewers: quinnj, Octogonapus
106+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)