blob: b76a6cda78f6ddc44f501266fc905d434e274553 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
"""Add a release comment to all the issues mentioned in the latest release."""
import json
import re
import time
import requests
with open("tmp/relnotes.json") as frn:
relnotes = json.load(frn)
latest = relnotes[0]
version = latest["version"]
comment = (
f"This is now released as part of [coverage {version}]" +
f"(https://pypi.org/project/coverage/{version})."
)
print(f"Comment will be: {comment}")
owner = "nedbat"
repo = "coveragepy"
for m in re.finditer(r"https://github.com/nedbat/coveragepy/(issues|pull)/(\d+)", latest["text"]):
kind, number = m.groups()
if kind == "issues":
print(f"Commenting on {m[0]}")
url = f"https://api.github.com/repos/{owner}/{repo}/issues/{number}/comments"
resp = requests.post(url, json={"body": comment})
print(resp)
time.sleep(1)
else:
print(f"You need to manually coment on {m[0]}")
|