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
9 changes: 7 additions & 2 deletions .github/scripts/pins_pr_body.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Write the body of the template action pins PR, with the release notes of each bump.

Reads the pin changes from `git diff` of the template's workflows, and fetches the
notes of every release in each bumped range with `gh`. Prints the body to stdout.
notes of every release in each bumped range with `gh`. Prints the body to stdout, and
writes the list of bumps, for the commit message, to the path given as an argument.
"""

import json
Expand Down Expand Up @@ -126,8 +127,12 @@ def release_notes(repo: str, old: str, new: str) -> str:


def main() -> None:
changes = pin_changes()
bumps = "".join(f"- {repo} {old} → {new}\n" for repo, (old, new) in changes.items())
with open(sys.argv[1], "w", encoding="utf-8") as f:
f.write(bumps)
body = INTRO + "\n## Release notes\n\n"
for repo, (old, new) in pin_changes().items():
for repo, (old, new) in changes.items():
try:
section = release_notes(repo, old, new)
except subprocess.CalledProcessError as exc:
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/update-template-pins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,27 @@ jobs:
done

- name: Write the pull request body, with release notes
id: body
env:
GH_TOKEN: ${{ github.token }}
run: python3 .github/scripts/pins_pr_body.py > "$RUNNER_TEMP/pr-body.md"
run: |
python3 .github/scripts/pins_pr_body.py "$RUNNER_TEMP/bumps.txt" > "$RUNNER_TEMP/pr-body.md"
{
echo 'bumps<<EOF'
cat "$RUNNER_TEMP/bumps.txt"
echo 'EOF'
} >> "$GITHUB_OUTPUT"

- name: Create pull request
id: cpr
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "ci: update action pins in the template"
# The squash merge takes its message from this commit's body.
commit-message: |
ci: update action pins in the template

${{ steps.body.outputs.bumps }}
title: "⬆️ Update action pins in the template"
body-path: ${{ runner.temp }}/pr-body.md
branch: ci/template-action-pins
Expand Down
Loading