Files
bifrost-registry/scripts/main.py
T

38 lines
1014 B
Python
Raw Normal View History

2025-05-09 16:16:37 +07:00
from gitea.api import GiteaApi
from gitea.config import GiteaConfig
import giteapy
import os
import json
2025-05-09 16:23:04 +07:00
from datetime import datetime
2025-05-09 16:16:37 +07:00
2025-05-09 16:45:47 +07:00
from gitea import GiteaUtils
2025-05-09 16:38:42 +07:00
2025-05-09 16:49:50 +07:00
current_file_path = os.path.abspath(__file__)
params = {
"owner": "CDN",
"repo": "bifrost-registry",
"release_id": 8845,
"attachment_path": os.path.abspath(
os.path.join(os.path.dirname(current_file_path), "..", "registry.zip")
),
}
2025-05-09 16:16:37 +07:00
def main():
gitea_instance = GiteaApi()
2025-05-09 16:45:47 +07:00
gitea_utils = GiteaUtils(gitea_instance)
assets = gitea_utils.get_release(**params).assets
2025-05-09 17:32:07 +07:00
if not os.path.isfile(params["attachment_path"]):
print(f"File {params['attachment_path']} does not exist")
exit(1)
2025-05-09 16:45:47 +07:00
gitea_utils.update_release(**params)
2025-05-09 16:16:37 +07:00
for asset in assets:
if asset.name == "registry.zip":
2025-05-09 16:38:42 +07:00
params["attachment_id"] = asset.id
2025-05-09 16:45:47 +07:00
gitea_utils.delete_release_attachment(**params)
gitea_utils.create_release_attachment(**params)
2025-05-09 16:16:37 +07:00
if __name__ == "__main__":
main()