From 6dbbb8f2a11c06abf3b8ffeba24c871ce0364bd1 Mon Sep 17 00:00:00 2001 From: erik Date: Thu, 3 Aug 2023 12:45:53 +0200 Subject: [PATCH] [Skip-CI] Add ArtifactDeploymentApi --- .../infrastructure/infrastructure.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/python/ddadevops/infrastructure/infrastructure.py b/src/main/python/ddadevops/infrastructure/infrastructure.py index 99ec45c..2c27fb1 100644 --- a/src/main/python/ddadevops/infrastructure/infrastructure.py +++ b/src/main/python/ddadevops/infrastructure/infrastructure.py @@ -206,3 +206,23 @@ class GitApi: class TerraformApi: 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") + + + \ No newline at end of file