Skip to content

Commit d893ac8

Browse files
authored
Added a workflow to bump downstream versions (#13434)
1 parent 026721b commit d893ac8

File tree

5 files changed

+115
-3
lines changed

5 files changed

+115
-3
lines changed

.github/bin/bump_downstreams.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Extract downstream info from ci.yml using yq
4+
DOWNSTREAMS=$(yq '.jobs.linux-downstream.strategy.matrix.include[] | .DOWNSTREAM + ":" + .REPO + ":" + .REF' .github/workflows/ci.yml)
5+
echo "Found downstreams:"
6+
echo "$DOWNSTREAMS"
7+
8+
# Create individual bump steps for each downstream
9+
HAS_ANY_UPDATES=false
10+
COMBINED_COMMIT_MSG=""
11+
12+
while IFS=: read -r downstream repo ref; do
13+
echo "Processing $downstream..."
14+
15+
# Convert repo to GitHub URL
16+
repo_url="https://github.com/$repo"
17+
18+
# Extract branch name and determine if it's a tag from the comment in ci.yml
19+
# Find the comment line for this downstream by looking for the REF line and getting the comment above it
20+
comment_line=$(grep -B1 "REF: $ref" .github/workflows/ci.yml | grep "^[[:space:]]*#" | tail -1)
21+
22+
# Parse the comment to determine branch and whether it's a tag
23+
if echo "$comment_line" | grep -q "release tag"; then
24+
# This is a tag-based entry
25+
tag_args="--tag"
26+
branch="" # Not used for tags
27+
comment_pattern="# Latest release tag of $downstream, as of.*\\."
28+
else
29+
# This is a branch-based entry, extract branch name
30+
branch=$(echo "$comment_line" | sed -n 's/.*on the .* \([^ ]*\) branch.*/\1/p')
31+
tag_args=""
32+
comment_pattern="# Latest commit on the $downstream .* branch, as of.*\\."
33+
fi
34+
35+
echo "Using branch: $branch, tag_args: $tag_args"
36+
37+
# Create pattern to match REF in ci.yml
38+
ref_pattern="REF: ($ref)"
39+
replacement_pattern="REF: {new_version}"
40+
41+
# Run bump_dependency.py
42+
python3 .github/bin/bump_dependency.py \
43+
--name "$downstream" \
44+
--repo-url "$repo_url" \
45+
--branch "$branch" \
46+
--file-path ".github/workflows/ci.yml" \
47+
--current-version-pattern "$ref_pattern" \
48+
--update-pattern "$replacement_pattern" \
49+
--comment-pattern "$comment_pattern" \
50+
$tag_args
51+
52+
# Check if this downstream had updates
53+
if [ -f "$GITHUB_OUTPUT" ]; then
54+
if grep -q "HAS_UPDATES=true" "$GITHUB_OUTPUT"; then
55+
HAS_ANY_UPDATES=true
56+
# Extract commit message for this downstream
57+
DOWNSTREAM_MSG=$(sed -n '/COMMIT_MSG<<EOF/,/^EOF$/p' "$GITHUB_OUTPUT" | sed '1d;$d')
58+
if [ -n "$COMBINED_COMMIT_MSG" ]; then
59+
COMBINED_COMMIT_MSG="$COMBINED_COMMIT_MSG"$'\n\n'"$DOWNSTREAM_MSG"
60+
else
61+
COMBINED_COMMIT_MSG="$DOWNSTREAM_MSG"
62+
fi
63+
fi
64+
fi
65+
done <<< "$DOWNSTREAMS"
66+
67+
# Set final outputs
68+
echo "HAS_UPDATES=$HAS_ANY_UPDATES" >> "$GITHUB_OUTPUT"
69+
if [ "$HAS_ANY_UPDATES" = "true" ]; then
70+
echo "COMMIT_MSG<<EOF" >> "$GITHUB_OUTPUT"
71+
echo "$COMBINED_COMMIT_MSG" >> "$GITHUB_OUTPUT"
72+
echo "EOF" >> "$GITHUB_OUTPUT"
73+
fi
File renamed without changes.

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ jobs:
445445
# Latest commit on the twisted trunk branch, as of Aug 05, 2025.
446446
REF: 710e6fad358efe58262ff49c9e32af594687a794
447447
PATH: twisted
448-
- DOWNSTREAM: aws-encryption-sdk
448+
- DOWNSTREAM: aws-encryption-sdk-python
449449
REPO: awslabs/aws-encryption-sdk-python
450450
# Latest commit on the aws-encryption-sdk-python master branch, as of Aug 05, 2025.
451451
REF: cbfab663e94c4ed1db5211886770e1aa403a7c67
@@ -462,7 +462,7 @@ jobs:
462462
PATH: certbot
463463
- DOWNSTREAM: certbot-josepy
464464
REPO: certbot/josepy
465-
# Latest commit on the josepy main branch, as of Aug 05, 2025.
465+
# Latest commit on the certbot-josepy main branch, as of Aug 05, 2025.
466466
REF: f74100c800fd280f0640d320052a9680da56be95
467467
PATH: josepy
468468
- DOWNSTREAM: mitmproxy
@@ -475,7 +475,7 @@ jobs:
475475
# Latest commit on the scapy master branch, as of Aug 05, 2025.
476476
REF: cc8e09187407cefce61207823239c2d5749bf046
477477
PATH: scapy
478-
- DOWNSTREAM: sigstore
478+
- DOWNSTREAM: sigstore-python
479479
REPO: sigstore/sigstore-python
480480
# Latest commit on the sigstore-python main branch, as of Aug 05, 2025.
481481
REF: 5ea398f538ea1954c9aca9cf6064d1d93ccbced1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bump downstream dependencies
2+
permissions:
3+
contents: read
4+
5+
on:
6+
workflow_dispatch:
7+
schedule:
8+
# Run daily
9+
- cron: "0 0 * * *"
10+
11+
jobs:
12+
bump:
13+
if: github.repository_owner == 'pyca'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
with:
18+
# Needed so we can push back to the repo
19+
persist-credentials: true
20+
- name: Parse downstream dependencies
21+
id: downstream-bump
22+
run: ./.github/bin/bump_downstreams.sh
23+
- uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
24+
id: generate-token
25+
with:
26+
app_id: ${{ secrets.BORINGBOT_APP_ID }}
27+
private_key: ${{ secrets.BORINGBOT_PRIVATE_KEY }}
28+
if: steps.downstream-bump.outputs.HAS_UPDATES == 'true'
29+
- name: Create Pull Request
30+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
31+
with:
32+
branch: "bump-downstreams"
33+
commit-message: "Bump downstream dependencies in CI"
34+
title: "Bump downstream dependencies in CI"
35+
author: "pyca-boringbot[bot] <pyca-boringbot[bot][email protected]>"
36+
body: |
37+
${{ steps.downstream-bump.outputs.COMMIT_MSG }}
38+
token: ${{ steps.generate-token.outputs.token }}
39+
if: steps.downstream-bump.outputs.HAS_UPDATES == 'true'

0 commit comments

Comments
 (0)