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

Conversation

clobrano
Copy link
Contributor

@clobrano clobrano commented Sep 27, 2024

Why we need this PR

Automate the creation of a social media post for Medik8s release announcements, which is expected to speed up the process and make it more consistent.

Changes made

A python script that depends on packages (in requirements.txt)

  • requests
  • markdown

able to format a social media post announcing our releases.
The script will pick, for each operator, the latest tag name and related
URL to release note, and format a message in raw markdown and HTML.

Which issue(s) this PR fixes

Test plan

$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python ./product_release_post.py

Limitations

There's a (currently unhandled) rate limit to the use of APIs. It is
enough for around 10 retries. When reached the script fails with error

KeyError: 'tag_name'

TODO

  • handle APIs rate limit
  • fix conversion of markdown lists in html
  • move the script to a proper subdir

Copy link

openshift-ci bot commented Sep 27, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: clobrano

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

A python script that depends on packages (in requirements.txt)
* requests
* markdown

able to format a social media post announcing our releases.
The script will pick, for each operator, the latest tag name and related
URL to release note, and format a message in raw markdown and HTML.

suggested use

$ python -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python ./product_release_post.py

Limitations
There's a (currently unhandled) rate limit to the use of APIs. It is
enough for around 10 retries. When reached the script fails with error

```
KeyError: 'tag_name'
```

Signed-off-by: Carlo Lobrano <[email protected]>
@clobrano clobrano force-pushed the community-message-templating branch from 565e594 to 1c26dfd Compare September 27, 2024 07:59
@clobrano
Copy link
Contributor Author

clobrano commented Sep 27, 2024

Here the result of running the script

EDIT: the script does not print on std output anymore. It creates 2 files, one release.md and one release.html

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

❯ ./product_rel_announcement.py --html --markdown
❯ ls
Makefile  product_rel_announcement.py  release.html  release.md  requirements.txt  venv

❯ cat release.md
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: release.md
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │
   2   │ Medik8s New Releases
   3   │
   4   │ The Medik8s team is thrilled to announce the new releases of ours operators
   5   │
   6   │ * Node Maintenance Operator (NMO)    v0.17.0 ([release note](https://github.com/medik8s/node-maintenance-operator/releases/tag/v0.17.0))
   7   │ * Node Healthcheck Operator (NHC)    v0.7.0 ([release note](https://github.com/medik8s/node-healthcheck-operator/releases/tag/v0.7.0))
   8   │ * Self Node Remediation (SNR)        v0.9.0 ([release note](https://github.com/medik8s/self-node-remediation/releases/tag/v0.9.0))
   9   │ * Fence Agents Remediation (FAR)     v0.4.0 ([release note](https://github.com/medik8s/fence-agents-remediation/releases/tag/v0.4.0))
  10   │ * Machine Deletion Remediation (MDR) v0.3.0 ([release note](https://github.com/medik8s/machine-deletion-remediation/releases/tag/v0.3.0))
  11   │
  12   │ see our release notes for the complete list of changes.
  13   │
  14   │ Feel free to explore the new operators and contact us if you need any assistance.
  15   │
  16   │ Do not forget to visit [https://www.medik8s.io/](https://www.medik8s.io/) for the latest information on the team's operators,
  17   │ Best regards from the Medik8s team.
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

❯ cat release.html
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: release.html
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ <p>Medik8s New Releases</p>
   2   │ <p>The Medik8s team is thrilled to announce the new releases of ours operators</p>
   3   │ <ul>
   4   │ <li>Node Maintenance Operator (NMO)    v0.17.0 (<a href="https://github.com/medik8s/node-maintenance-operator/releases/tag/v0.17.0">release note</a>)</li>
   5   │ <li>Node Healthcheck Operator (NHC)    v0.7.0 (<a href="https://github.com/medik8s/node-healthcheck-operator/releases/tag/v0.7.0">release note</a>)</li>
   6   │ <li>Self Node Remediation (SNR)        v0.9.0 (<a href="https://github.com/medik8s/self-node-remediation/releases/tag/v0.9.0">release note</a>)</li>
   7   │ <li>Fence Agents Remediation (FAR)     v0.4.0 (<a href="https://github.com/medik8s/fence-agents-remediation/releases/tag/v0.4.0">release note</a>)</li>
   8   │ <li>Machine Deletion Remediation (MDR) v0.3.0 (<a href="https://github.com/medik8s/machine-deletion-remediation/releases/tag/v0.3.0">release note</a>)</li>
   9   │ </ul>
  10   │ <p>see our release notes for the complete list of changes.</p>
  11   │ <p>Feel free to explore the new operators and contact us if you need any assistance.</p>
  12   │ <p>Do not forget to visit <a href="https://www.medik8s.io/">https://www.medik8s.io/</a> for the latest information on the team's operators,
  13   │ Best regards from the Medik8s team.</p>
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

@clobrano
Copy link
Contributor Author

It seems that HTML formatting doesn't recognize correctly the lists 🤔

Copy link
Member

@slintes slintes left a comment

Choose a reason for hiding this comment

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

nice

  • can we have this in a meaningful subdir please?
  • what about a Makefile for easier usage?

@clobrano
Copy link
Contributor Author

I agree that the subdir is a good idea, but I’m not sure I see the added value of the Makefile here. As I understand it, we'd be moving from running ./product_release_post.py (once the script is executable) to make release_post, which seems the same to me.

Comment on lines 7 to 13
products_map = {
"NMO": "node-maintenance-operator",
"NHC": "node-healthcheck-operator",
"SNR": "self-node-remediation",
"FAR": "fence-agents-remediation",
"MDR": "machine-deletion-remediation",
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was an experiment, but I don't see anymore any benefit in having this map. I will just use the full name when necessary

"FAR": "fence-agents-remediation",
"MDR": "machine-deletion-remediation",
}
# print(requests.get(f'https://api.github.com/repos/medik8s/{products_map["MDR"]}/releases/latest').json())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove this commented code

* Use dedicated folder ProductReleaseAnnouncement
* Announce the Operators and report the link to the release notes in the same list
Add Usage doc and argument parsing logic with docopt-ng.

The script now write the announcement post in:
* release.md Markdown file if using the flag --markdown/-m
* release.html file if using the flag --html/-w

the flags can be used together to have two formats.
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.

Signed-off-by: Carlo Lobrano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants