Skip to content

Commit a82ddb9

Browse files
tstellarllvmbot
authored andcommitted
[workflows] Add a job for requesting a release note on release branch PRs (llvm#91826)
We have been collecting release notes from the PRs for most of the 18.1.x releases and this just helps automate the process. (cherry picked from commit c99d115)
1 parent 09615ce commit a82ddb9

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: PR Request Release Note
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
on:
8+
pull_request:
9+
types:
10+
- closed
11+
12+
jobs:
13+
request-release-note:
14+
if: >-
15+
github.repository_owner == 'llvm' &&
16+
startsWith(github.ref, 'refs/heads/release')
17+
18+
runs-on: ubuntu-latest
19+
steps:
20+
# We need to pull the script from the main branch, so that we ensure
21+
# we get the latest version of this script.
22+
- name: Checkout Scripts
23+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
24+
with:
25+
sparse-checkout: |
26+
llvm/utils/git/requirements.txt
27+
llvm/utils/git/github-automation.py
28+
sparse-checkout-cone-mode: false
29+
30+
- name: Install Dependencies
31+
run: |
32+
pip install -r llvm/utils/git/requirements.txt
33+
34+
- name: Request Release Note
35+
env:
36+
# We need to use an llvmbot token here, because we are mentioning a user.
37+
GITHUB_TOKEN: ${{ github.token }}
38+
run: |
39+
python3 llvm/utils/git/github-automation.py \
40+
--repo "$GITHUB_REPOSITORY" \
41+
--token "$GITHUB_TOKEN" \
42+
request-release-note \
43+
--pr-number ${{ github.event.pull_request.number}}

llvm/utils/git/github-automation.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,25 @@ def execute_command(self) -> bool:
675675
return False
676676

677677

678+
def request_release_note(token: str, repo_name: str, pr_number: int):
679+
repo = github.Github(token).get_repo(repo_name)
680+
pr = repo.get_issue(pr_number).as_pull_request()
681+
submitter = pr.user.login
682+
if submitter == "llvmbot":
683+
m = re.search("Requested by: @(.+)$", pr.body)
684+
if not m:
685+
submitter = None
686+
print("Warning could not determine user who requested backport.")
687+
submitter = m.group(1)
688+
689+
mention = ""
690+
if submitter:
691+
mention = f"@{submitter}"
692+
693+
comment = f"{mention} (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR. "
694+
pr.as_issue().create_comment(comment)
695+
696+
678697
parser = argparse.ArgumentParser()
679698
parser.add_argument(
680699
"--token", type=str, required=True, help="GitHub authentiation token"
@@ -736,6 +755,18 @@ def execute_command(self) -> bool:
736755
help="Set the default user and email for the git repo in LLVM_PROJECT_DIR to llvmbot",
737756
)
738757

758+
request_release_note_parser = subparsers.add_parser(
759+
"request-release-note",
760+
help="Request a release note for a pull request",
761+
)
762+
request_release_note_parser.add_argument(
763+
"--pr-number",
764+
type=int,
765+
required=True,
766+
help="The pull request to request the release note",
767+
)
768+
769+
739770
args = parser.parse_args()
740771

741772
if args.command == "issue-subscriber":
@@ -771,3 +802,5 @@ def execute_command(self) -> bool:
771802
sys.exit(1)
772803
elif args.command == "setup-llvmbot-git":
773804
setup_llvmbot_git()
805+
elif args.command == "request-release-note":
806+
request_release_note(args.token, args.repo, args.pr_number)

0 commit comments

Comments
 (0)