[Skip-CI] Add ArtifactDeploymentApi

This commit is contained in:
erik 2023-08-03 12:45:53 +02:00
parent e6450b796f
commit 6dbbb8f2a1

View file

@ -206,3 +206,23 @@ class GitApi:
class TerraformApi: class TerraformApi:
pass pass
class ArtifactDeploymentApi:
def __init__(self):
self.execution_api = ExecutionApi()
def post_release(self, target_url: str, token: str, tag: str):
self.execution_api.execute_secure(f"curl -X 'POST' '{target_url}' -H 'accept: application/json' -H 'Content-Type: application/json' -d " +
"'{ \"body\": \"Provides files for release " + tag + "\\nAttention: The \\\"Source Code\\\"-files below are not up-to-date!\", " + f"\"tag_name\": \"{tag}\"" + "}'" +
f"-H \"Authorization: token {token}\"")
def post_asset(self, target_url: str, release_id: str, token: str, attachment: str, type: str):
self.execution_api.execute_secure(f"curl -X 'POST' '{target_url}/{release_id}/assets' -H 'accept: application/json' -H \"Authorization: token {token}\" -H 'Content-Type: multipart/form-data' -F 'attachment=@{attachment};type={type}'")
def calculate_checksums(self, build_path: str):
self.execution_api.execute("find " + build_path + " -type f -exec sha256sum {} \\; | sort > " + build_path + "sha256sum.lst")
self.execution_api.execute("find " + build_path + " -type f -exec sha512sum {} \\; | sort > " + build_path + "sha512sum.lst")