-
Notifications
You must be signed in to change notification settings - Fork 3
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
clobrano
wants to merge
5
commits into
medik8s:main
Choose a base branch
from
clobrano:community-message-templating
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1c26dfd
Automatic formatting of Social media release announcement
clobrano 35e6f40
Use dedicated folder and fix format
clobrano e4ec6d4
Move main code into a main() function
clobrano 43a59e5
Add argument parser logic
clobrano 1c9eb9f
Minor fixes in message format
clobrano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
-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() | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I thought that if we begin automating the message, then extending it to the above use case would make sense.