Skip to content

Commit 79d97ed

Browse files
authored
CSHARP-4918: Release notes automation (#1680)
1 parent 6b3835c commit 79d97ed

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

.github/workflows/pr.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Pull Request validation
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- edited
9+
- labeled
10+
- unlabeled
11+
12+
jobs:
13+
pull-request-validation:
14+
name: Pull Request validation.
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Pull Request should have a label assigned.
18+
if: ${{ always() && github.event.pull_request.labels[0] == null }}
19+
run: |
20+
exit 1
21+
22+
- name: Title should start with a Jira ticket.
23+
if: ${{ always() && !(startsWith(github.event.pull_request.title, 'CSHARP-')) }}
24+
run: |
25+
exit 1
26+
27+
- name: Title should not end with period or ellipses.
28+
if: ${{ always() && (endsWith(github.event.pull_request.title, '.') || endsWith(github.event.pull_request.title, '…')) }}
29+
run: |
30+
exit 1

evergreen/release-notes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def load_config(opts):
3737

3838

3939
def mapPullRequest(pullRequest, opts):
40-
title = pullRequest["title"]
40+
title = pullRequest["title"].encode('ascii', 'backslashreplace').decode().replace("<", "\<")
4141
for regex in opts.template["autoformat"]:
4242
title = re.sub(regex["match"], regex["replace"], title)
4343

@@ -91,7 +91,9 @@ def load_pull_requests(opts):
9191
github_api_base_url=opts.github_api_base_url,
9292
repo=opts.repo,
9393
commit_sha=commit["sha"])
94-
pullrequests = requests.get(pullrequests_url, headers=opts.github_headers).json()
94+
pullrequests_response = requests.get(pullrequests_url, headers=opts.github_headers)
95+
pullrequests_response.raise_for_status()
96+
pullrequests = pullrequests_response.json()
9597
for pullrequest in pullrequests:
9698
mapped = mapPullRequest(pullrequest, opts)
9799
if is_in_section(mapped, ignore_section):
@@ -140,7 +142,6 @@ def publish_release_notes(opts, title, content):
140142
print("Publishing release notes...")
141143
url = '{github_api_base_url}{repo}/releases/tags/{tag}'.format(github_api_base_url=opts.github_api_base_url, repo=opts.repo, tag=opts.version_tag)
142144
response = requests.get(url, headers=opts.github_headers)
143-
response.raise_for_status()
144145
if response.status_code != 404:
145146
raise SystemExit("Release with the tag already exists")
146147

0 commit comments

Comments
 (0)