Skip to content

Commit

Permalink
Switch to latest release message builder
Browse files Browse the repository at this point in the history
  • Loading branch information
stevelacey committed Nov 10, 2022
1 parent e42995b commit 4367149
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/release_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
).get(DEPLOY_STATUS or "pending")
action_url = f"{github_url}/actions/runs/{GITHUB_RUN_ID}"

image_html_re = re.compile(r'<img.*?alt="(.*?)".*?src="(.*?)".*?>')
image_md_re = re.compile(r"!\[(.*?)\]\((.*?)\)")

release_re = re.compile(
r"""
^\#+\s
Expand Down Expand Up @@ -68,10 +71,10 @@ def build_message():
"type": "plain_text",
"text": text,
},
"image_url": image,
"image_url": url,
"alt_text": text,
}
for text, image in images
for text, url in images
],
}

Expand All @@ -97,6 +100,10 @@ def build_message():
}


def find_images(text):
return image_html_re.findall(text) + image_md_re.findall(text)


def get_images(release):
images = []

Expand All @@ -118,10 +125,9 @@ def get_images(release):

images.extend(
[
(f"{pull['title']} #{pull['number']}: {text}".strip(": "), image)
for text, image in re.findall(
r"!\[(.*?)\]\((.*?)\)", pull["body"] or ""
)
(f"{pull['title']} #{pull['number']}: {text}".strip(": "), url)
for text, url in find_images(pull["body"] or "")
if "badge" not in url
]
)

Expand Down Expand Up @@ -161,7 +167,10 @@ def transform_markdown(text):
text = re.sub(r"!?\[([^\[\]]*?)\]\(([^\(\)]*?)\)", r"<\2|\1>", text)
# convert lists into bullets
text = re.sub(
r"(?<=^) *[·•●\-\*➤]+ *(.*)", r" *•* \1", text, flags=re.MULTILINE
r"(?<=^) *[·•●\-\*➤]+\s*(.*)",
r" *•*  \1",
text,
flags=re.MULTILINE,
)
# convert headings into bold
text = re.sub(
Expand Down

0 comments on commit 4367149

Please sign in to comment.