Skip to content

Commit

Permalink
New format for changelog with release dates (#1494)
Browse files Browse the repository at this point in the history
  • Loading branch information
yceballost authored Oct 18, 2023
1 parent 0de729e commit 6aee774
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 90 deletions.
59 changes: 35 additions & 24 deletions .github/resources/changelog-index-generator.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,64 @@
import os

# pip install packaging
from packaging.version import parse as parse_version
from datetime import datetime
import git

BREAK = "\n"

# folder path
dir_path = r'./changelog-versions'

# list to store files
changelog_files_extension = []
# list to store files with creation dates and first commit dates
changelog_files_with_dates = []

# Iterate directory
for path in os.listdir(dir_path):
# check if current path is a file
if os.path.isfile(os.path.join(dir_path, path)):
changelog_files_extension.append(path)
if path == ".DS_Store":
changelog_files_extension.remove(path)
# print(changelog_files_extension)
file_name = path.replace('.md', '') # Remove extension
file_path = os.path.join(dir_path, path)

# Get first commit date using gitpython
repo = git.Repo(search_parent_directories=True)
first_commit_date = repo.git.log('--format=%aI', '--', file_path).splitlines()[-1]

# Remove extension from files
changelog_files = list(
map(lambda x: x.replace('.md', ''), changelog_files_extension))
# print(changelog_files)
# Format the date
first_commit_date = datetime.fromisoformat(first_commit_date).strftime('%Y-%m-%d')

changelog_files_with_dates.append((file_name, first_commit_date))

# Sort files by version
changelog_files_sorted = sorted(changelog_files, reverse=True, key=lambda x: [int(
i) if i.isdigit() else i for i in x.split('.')])
print(changelog_files_sorted)
changelog_files_with_dates_sorted = sorted(changelog_files_with_dates, reverse=True, key=lambda x: [int(
i) if i.isdigit() else i for i in x[0].split('.')])

# Generate list of versions in HTML table format
changelog_version = ""

# Generate list of versions in markdown format
for item in changelog_files_sorted:
# print(item)
# If version is major, then use ## for make this version as a "large" title
major = "## " if item.endswith('.0.0') else ""
changelog_version += major + "[" + item + "]" + \
"(" + "changelog-versions/" + item + ".md" + ")" + BREAK + BREAK
# print(changelog_version)
# Agregar el encabezado de la tabla en HTML
changelog_version += "<table>\n"
changelog_version += "<tr><th align=\"left\">Version</th><th align=\"left\">Release date</th></tr>\n"

for item, first_commit_date in changelog_files_with_dates_sorted:
if item.endswith('.0.0'):
major = f"<strong><a href='changelog-versions/{item}.md'>{item}</a></strong>"
else:
major = f"<a href='changelog-versions/{item}.md'>{item}</a>"

# Agregar una fila de la tabla en HTML para cada versión
changelog_version += f"<tr ><td width=\"500px\">{major}</td><td width=\"500px\">{first_commit_date}</td></tr>\n"

# Cerrar la tabla HTML
changelog_version += "</table>\n"

# Agregar saltos de línea según tu BREAK
changelog_version += BREAK + BREAK

# Empty line
print()

# Draw markdown file
file_content = "# Figma Changelog" + BREAK + BREAK + changelog_version + "---" + BREAK + \
"[Changelog history →](https://paper.dropbox.com/doc/Changelog-Mistica-Design-System--BlDyPv0kWq8W502b64VVIPMsAQ-il1pWXaGur0Nm88P831X2)" + BREAK
print(file_content)

# Save file
output_file_path = "./CHANGELOG.md"
Expand Down
103 changes: 37 additions & 66 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,72 +1,43 @@
# Figma Changelog

[11.1.0](changelog-versions/11.1.0.md)
<table>
<tr><th align="left">Version</th><th align="left">Release date</th></tr>
<tr ><td width="500px"><a href='changelog-versions/11.1.0.md'>11.1.0</a></td><td width="500px">2023-10-16</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/11.0.0.md'>11.0.0</a></strong></td><td width="500px">2023-10-10</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/10.0.0.md'>10.0.0</a></strong></td><td width="500px">2023-10-02</td></tr>
<tr ><td width="500px"><a href='changelog-versions/9.3.0.md'>9.3.0</a></td><td width="500px">2023-09-11</td></tr>
<tr ><td width="500px"><a href='changelog-versions/9.2.0.md'>9.2.0</a></td><td width="500px">2023-09-01</td></tr>
<tr ><td width="500px"><a href='changelog-versions/9.1.0.md'>9.1.0</a></td><td width="500px">2023-07-31</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/9.0.0.md'>9.0.0</a></strong></td><td width="500px">2023-07-04</td></tr>
<tr ><td width="500px"><a href='changelog-versions/8.4.0.md'>8.4.0</a></td><td width="500px">2023-06-12</td></tr>
<tr ><td width="500px"><a href='changelog-versions/8.3.0.md'>8.3.0</a></td><td width="500px">2023-05-26</td></tr>
<tr ><td width="500px"><a href='changelog-versions/8.2.0.md'>8.2.0</a></td><td width="500px">2023-05-16</td></tr>
<tr ><td width="500px"><a href='changelog-versions/8.1.0.md'>8.1.0</a></td><td width="500px">2023-04-27</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/8.0.0.md'>8.0.0</a></strong></td><td width="500px">2023-04-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/7.3.0.md'>7.3.0</a></td><td width="500px">2023-02-27</td></tr>
<tr ><td width="500px"><a href='changelog-versions/7.2.0.md'>7.2.0</a></td><td width="500px">2023-02-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/7.1.1.md'>7.1.1</a></td><td width="500px">2023-01-30</td></tr>
<tr ><td width="500px"><a href='changelog-versions/7.1.0.md'>7.1.0</a></td><td width="500px">2023-01-27</td></tr>
<tr ><td width="500px"><a href='changelog-versions/7.0.2.md'>7.0.2</a></td><td width="500px">2023-01-20</td></tr>
<tr ><td width="500px"><a href='changelog-versions/7.0.1.md'>7.0.1</a></td><td width="500px">2023-01-13</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/7.0.0.md'>7.0.0</a></strong></td><td width="500px">2023-01-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/6.3.0.md'>6.3.0</a></td><td width="500px">2022-11-25</td></tr>
<tr ><td width="500px"><a href='changelog-versions/6.2.0.md'>6.2.0</a></td><td width="500px">2022-11-14</td></tr>
<tr ><td width="500px"><a href='changelog-versions/6.1.0.md'>6.1.0</a></td><td width="500px">2022-10-31</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/6.0.0.md'>6.0.0</a></strong></td><td width="500px">2022-09-30</td></tr>
<tr ><td width="500px"><a href='changelog-versions/5.4.0.md'>5.4.0</a></td><td width="500px">2022-08-26</td></tr>
<tr ><td width="500px"><a href='changelog-versions/5.3.0.md'>5.3.0</a></td><td width="500px">2022-08-12</td></tr>
<tr ><td width="500px"><a href='changelog-versions/5.2.2.md'>5.2.2</a></td><td width="500px">2022-08-04</td></tr>
<tr ><td width="500px"><a href='changelog-versions/5.2.1.md'>5.2.1</a></td><td width="500px">2022-08-01</td></tr>
<tr ><td width="500px"><a href='changelog-versions/5.2.0.md'>5.2.0</a></td><td width="500px">2022-07-29</td></tr>
<tr ><td width="500px"><a href='changelog-versions/5.1.0.md'>5.1.0</a></td><td width="500px">2022-07-14</td></tr>
<tr ><td width="500px"><strong><a href='changelog-versions/5.0.0.md'>5.0.0</a></strong></td><td width="500px">2022-07-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/4.11.0.md'>4.11.0</a></td><td width="500px">2022-07-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/4.10.0.md'>4.10.0</a></td><td width="500px">2022-07-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/4.9.0.md'>4.9.0</a></td><td width="500px">2022-07-10</td></tr>
<tr ><td width="500px"><a href='changelog-versions/4.8.0.md'>4.8.0</a></td><td width="500px">2022-07-10</td></tr>
</table>

## [11.0.0](changelog-versions/11.0.0.md)

## [10.0.0](changelog-versions/10.0.0.md)

[9.3.0](changelog-versions/9.3.0.md)

[9.2.0](changelog-versions/9.2.0.md)

[9.1.0](changelog-versions/9.1.0.md)

## [9.0.0](changelog-versions/9.0.0.md)

[8.4.0](changelog-versions/8.4.0.md)

[8.3.0](changelog-versions/8.3.0.md)

[8.2.0](changelog-versions/8.2.0.md)

[8.1.0](changelog-versions/8.1.0.md)

## [8.0.0](changelog-versions/8.0.0.md)

[7.3.0](changelog-versions/7.3.0.md)

[7.2.0](changelog-versions/7.2.0.md)

[7.1.1](changelog-versions/7.1.1.md)

[7.1.0](changelog-versions/7.1.0.md)

[7.0.2](changelog-versions/7.0.2.md)

[7.0.1](changelog-versions/7.0.1.md)

## [7.0.0](changelog-versions/7.0.0.md)

[6.3.0](changelog-versions/6.3.0.md)

[6.2.0](changelog-versions/6.2.0.md)

[6.1.0](changelog-versions/6.1.0.md)

## [6.0.0](changelog-versions/6.0.0.md)

[5.4.0](changelog-versions/5.4.0.md)

[5.3.0](changelog-versions/5.3.0.md)

[5.2.2](changelog-versions/5.2.2.md)

[5.2.1](changelog-versions/5.2.1.md)

[5.2.0](changelog-versions/5.2.0.md)

[5.1.0](changelog-versions/5.1.0.md)

## [5.0.0](changelog-versions/5.0.0.md)

[4.11.0](changelog-versions/4.11.0.md)

[4.10.0](changelog-versions/4.10.0.md)

[4.9.0](changelog-versions/4.9.0.md)

[4.8.0](changelog-versions/4.8.0.md)

---
[Changelog history →](https://paper.dropbox.com/doc/Changelog-Mistica-Design-System--BlDyPv0kWq8W502b64VVIPMsAQ-il1pWXaGur0Nm88P831X2)

0 comments on commit 6aee774

Please sign in to comment.