Skip to content

Commit

Permalink
Add release file list
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlGao4 committed Aug 18, 2024
1 parent 09632f3 commit 97d3ca7
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions gh-actions-generate-toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
secret_key = os.environ["SECRET_KEY"]
bucket_name = os.environ["BUCKET_NAME"]

release_files = {}

s3 = boto3.client(
"s3", endpoint_url=endpoint_url, aws_access_key_id=access_key, aws_secret_access_key=secret_key, verify=True
)
Expand All @@ -93,6 +95,12 @@
filename = re.sub(
r"[\[\]_]", lambda m: f"\\{m[0]}", (i["Key"].rsplit("/", 1)[1] + " (CloudFlare)").replace("\\", "\\\\")
)
if "release" in parts[0]:
if catagory not in release_files:
release_files[catagory] = {}
if name not in release_files[catagory]:
release_files[catagory][name] = []
release_files[catagory][name].append(filename)
instruments[catagory][name][filename] = urllib.parse.urljoin(download_url_prefix, urllib.parse.quote(i["Key"]))
download_size[catagory][name][filename] = i["Size"]

Expand Down Expand Up @@ -124,14 +132,26 @@ def human_readable_size(size):
"- `sfz+flac.zip`: Converted SFZ files with FLAC audio files. You can use it directly in SFZ player.\n\n"
)

markdown += "## Converted Releases\n\n"
for catagory in sorted(release_files.keys()):
markdown += f"### {catagory}\n\n"
for name in sorted(release_files[catagory].keys()):
markdown += f"- {name}\n"
for asset in sorted(release_files[catagory][name], key=lambda x: x.rsplit(".", 1), reverse=True):
markdown += f" - {asset}\n"
markdown += "\n"

markdown += "## All Files\n\n"


for catagory in sorted(instruments.keys()):
markdown += f"## {catagory}\n\n"
markdown += f"### {catagory}\n\n"
for name in sorted(instruments[catagory].keys()):
if catagory in instrument_urls and name in instrument_urls[catagory]:
markdown += f"- [{name}]({instrument_urls[catagory][name]})\n"
else:
markdown += f"- {name}\n"
for asset in sorted(instruments[catagory][name].keys(), key=lambda x: x.rsplit(".", 1)[1]):
for asset in sorted(instruments[catagory][name].keys(), key=lambda x: x.rsplit(".", 1), reverse=True):
markdown += (
f" - [{asset}]({instruments[catagory][name][asset]}) "
f"({human_readable_size(download_size[catagory][name][asset])})\n"
Expand Down

0 comments on commit 97d3ca7

Please sign in to comment.