Skip to content

Commit

Permalink
📝 Release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-andre committed Apr 24, 2024
1 parent 2655c30 commit a8231f3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/publishing_docs_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ jobs:
run: |
sudo apt-get install -y libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev
sudo apt-get install -y pngquant
- name: Generate release notes
run: |
python docs_release_notes.py
if: ${{ success() }}

- name: Install AWS CLI
run: |
Expand Down
40 changes: 40 additions & 0 deletions docs_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import re
import requests
from datetime import datetime
from pathlib import Path
import shutil

release_notes_api_url = "https://api.github.com/repos/mauro-andre/pyodmongo/releases"
release_notes = requests.get(url=release_notes_api_url).json()

en_file_path = Path().absolute() / "docs" / "en" / "release_notes.md"
pt_file_path = Path().absolute() / "docs" / "pt-BR" / "release_notes.md"


def convert_text(input_text):
pattern = r"(@[\w-]+) in (\S+)"

def replace_link(match):
name = match.group(1)
url = match.group(2)
return f'<a href="{url}" target="_blank">{name}</a>'

converted_text = re.sub(pattern, replace_link, input_text)
return converted_text


with open(en_file_path, "w") as file:
file.write("# <center>Release notes</center> #\n\n")
for release_note in release_notes:
name = release_note.get("name")
published_at = datetime.fromisoformat(
release_note.get("published_at")
).strftime("%Y-%m-%d")
body: str = release_note.get("body")
body = convert_text(body)
body = body.replace("\n", "\n\n")
file.write("---\n")
file.write(f"## {name} - {published_at}\n")
file.write(f"{body}\n\n")

shutil.copy(en_file_path, pt_file_path)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ nav:
- indexes.md
- aggregation.md
- contributing.md
- release_notes.md

extra:
analytics:
Expand Down

0 comments on commit a8231f3

Please sign in to comment.