|
| 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 |
0 commit comments