Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic formatting of Social media release announcement #17

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions ProductReleaseAnnouncement/product_rel_announcement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vi: set ft=python :
"""
Auto-generate social media posts for Medik8s release announcements by filling in the latest tags and
release information.

Usage:
product_rel_announcement.py --markdown
product_rel_announcement.py --html
product_rel_announcement.py --html --markdown

Options:
Copy link
Member

@razo7 razo7 Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add another option for specifying a release of not all the operators but only some of them? It would work really nicely when we release all of them together, but that might not be the case
For example -- operator snr,mdr would lead to the announcement text of releasing only SNR and MDR.

Does that make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense yes.
Let's also say that with the new message (which I forgot to report), there is just 1 line per operator, so it is also easy to remove what's not released.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the message showing the the usage of the script

#17 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is just 1 line per operator, so it is also easy to remove what's not released.

Indeed, I thought that if we begin automating the message, then extending it to the above use case would make sense.

-m, --markdown Write the release announcement file release.md, in Markdown format
-w, --html Write the release announcement file release.html, in HTML format
"""
import requests
import markdown
from docopt import docopt


def main():
arguments = docopt(__doc__)
NMO = get_latest_version("node-maintenance-operator")
NHC = get_latest_version("node-healthcheck-operator")
SNR = get_latest_version("self-node-remediation")
FAR = get_latest_version("fence-agents-remediation")
MDR = get_latest_version("machine-deletion-remediation")

TEMPLATE = f"""
Medik8s New Releases

The Medik8s team is thrilled to announce the new releases of ours operators:

* Node Maintenance Operator (NMO) {NMO['tag']} ([release note]({NMO['link']}))
* Node Healthcheck Operator (NHC) {NHC['tag']} ([release note]({NHC['link']}))
* Self Node Remediation (SNR) {SNR['tag']} ([release note]({SNR['link']}))
* Fence Agents Remediation (FAR) {FAR['tag']} ([release note]({FAR['link']}))
* Machine Deletion Remediation (MDR) {MDR['tag']} ([release note]({MDR['link']}))

See our release notes for the complete list of changes.

Feel free to explore the new operators and contact us if you need any assistance.

Do not forget to visit [https://www.medik8s.io/](https://www.medik8s.io/) for the latest information on the team's operators,
Best regards from the Medik8s team.
"""

if arguments['--markdown']:
with open('release.md', 'w') as f:
f.write(TEMPLATE)

if arguments['--html']:
with open('release.html', 'w') as f:
html = markdown.markdown(TEMPLATE)
f.write(html)


def get_latest_version(op_name:str) -> dict[str,str]:
"""
Get the latest version of an Medik8s operator.

:param op_name: The name of the operator to retrieve the latest version for.
:return: A dictionary with the latest version tag and link to the release note.
"""
response = requests.get(f'https://api.github.com/repos/medik8s/{op_name}/releases/latest')
return {"tag":response.json()["tag_name"], "link": response.json()["html_url"]}


if __name__ == "__main__":
main()



3 changes: 3 additions & 0 deletions ProductReleaseAnnouncement/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
requests>=2.32
markdown>=3.7
docopt-ng>=0.9.0