Files
bifrost-registry/scripts/main.py
T

39 lines
1022 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:16:37 +07:00
def main():
gitea_instance = GiteaApi()
2025-05-09 16:45:47 +07:00
gitea_utils = GiteaUtils(gitea_instance)
2025-05-09 16:38:42 +07:00
current_file_path = os.path.abspath(__file__)
2025-05-09 16:16:37 +07:00
# Parameters
2025-05-09 16:38:42 +07:00
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
)
2025-05-09 16:38:42 +07:00
params = {
"owner": owner,
"repo": repo,
"release_id": release_id,
"attachment_path": attachment_path,
}
2025-05-09 16:45:47 +07:00
assets = gitea_utils.get_release(**params).assets
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()