From ed85bfb11be2456c8dc006f203ae3f656c7b885d Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 25 Jan 2022 13:23:29 -0500 Subject: build: latest tweaks to howto, and start of more automation --- ci/comment_on_fixes.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 ci/comment_on_fixes.py (limited to 'ci') diff --git a/ci/comment_on_fixes.py b/ci/comment_on_fixes.py new file mode 100644 index 00000000..b76a6cda --- /dev/null +++ b/ci/comment_on_fixes.py @@ -0,0 +1,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]}") -- cgit v1.2.1