Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .github/bin/bump_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def main() -> int:
default="{repo_url}/compare/{old_version}...{new_version}",
help="Template for diff URLs",
)
parser.add_argument(
"--commit-message-fd",
type=int,
help="File descriptor to write commit message to",
)

args = parser.parse_args()

Expand All @@ -154,8 +159,9 @@ def main() -> int:

if current_version == latest_version:
print(f"{args.name}: No update needed (current: {current_version})")
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write("HAS_UPDATES=false\n")
if not args.commit_message_fd:
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write("HAS_UPDATES=false\n")
return 0

print(
Expand All @@ -181,11 +187,15 @@ def main() -> int:
args.diff_url_template,
)

with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write("COMMIT_MSG<<EOF\n")
f.write(commit_msg)
f.write("\nEOF\n")
f.write("HAS_UPDATES=true\n")
if args.commit_message_fd:
with os.fdopen(args.commit_message_fd, "w") as f:
f.write(commit_msg)
else:
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write("COMMIT_MSG<<EOF\n")
f.write(commit_msg)
f.write("\nEOF\n")
f.write("HAS_UPDATES=true\n")

return 0

Expand Down
30 changes: 17 additions & 13 deletions .github/bin/bump_downstreams.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ while IFS=: read -r downstream repo ref; do
ref_pattern="REF: ($ref)"
replacement_pattern="REF: {new_version}"

# Run bump_dependency.py
# Create a temporary file for this downstream's commit message
TEMP_MSG_FILE=$(mktemp)

# Run bump_dependency.py with commit-message-fd redirected to the temp file
python3 .github/bin/bump_dependency.py \
--name "$downstream" \
--repo-url "$repo_url" \
Expand All @@ -47,21 +50,22 @@ while IFS=: read -r downstream repo ref; do
--current-version-pattern "$ref_pattern" \
--update-pattern "$replacement_pattern" \
--comment-pattern "$comment_pattern" \
$tag_args
--commit-message-fd 3 \
$tag_args 3<"$TEMP_MSG_FILE"

# Check if this downstream had updates
if [ -f "$GITHUB_OUTPUT" ]; then
if grep -q "HAS_UPDATES=true" "$GITHUB_OUTPUT"; then
HAS_ANY_UPDATES=true
# Extract commit message for this downstream
DOWNSTREAM_MSG=$(sed -n '/COMMIT_MSG<<EOF/,/^EOF$/p' "$GITHUB_OUTPUT" | sed '1d;$d')
if [ -n "$COMBINED_COMMIT_MSG" ]; then
COMBINED_COMMIT_MSG="$COMBINED_COMMIT_MSG"$'\n\n'"$DOWNSTREAM_MSG"
else
COMBINED_COMMIT_MSG="$DOWNSTREAM_MSG"
fi
# Check if this downstream had updates (commit message file has content)
if [ -s "$TEMP_MSG_FILE" ]; then
HAS_ANY_UPDATES=true
DOWNSTREAM_MSG=$(cat "$TEMP_MSG_FILE")
if [ -n "$COMBINED_COMMIT_MSG" ]; then
COMBINED_COMMIT_MSG="$COMBINED_COMMIT_MSG"$'\n\n'"$DOWNSTREAM_MSG"
else
COMBINED_COMMIT_MSG="$DOWNSTREAM_MSG"
fi
fi

# Clean up temp file
rm -f "$TEMP_MSG_FILE"
done <<< "$DOWNSTREAMS"

# Set final outputs
Expand Down
Loading