add some cleanup
This commit is contained in:
parent
4c0524aafe
commit
d643bba325
2 changed files with 18 additions and 15 deletions
|
@ -62,11 +62,12 @@ class ReleaseService:
|
||||||
self.git_api.push_follow_tags()
|
self.git_api.push_follow_tags()
|
||||||
|
|
||||||
def publish_artifacts(self, release: Release):
|
def publish_artifacts(self, release: Release):
|
||||||
|
token = str(release.release_artifact_token)
|
||||||
release_id = self.__parse_forgejo_release_id__(
|
release_id = self.__parse_forgejo_release_id__(
|
||||||
self.artifact_deployment_api.create_forgejo_release(
|
self.artifact_deployment_api.create_forgejo_release(
|
||||||
release.forgejo_release_api_endpoint(),
|
release.forgejo_release_api_endpoint(),
|
||||||
release.version.to_string(),
|
release.version.to_string(),
|
||||||
str(release.release_artifact_token),
|
token,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ class ReleaseService:
|
||||||
release.forgejo_release_asset_api_endpoint(release_id),
|
release.forgejo_release_asset_api_endpoint(release_id),
|
||||||
artifact.path(),
|
artifact.path(),
|
||||||
artifact.type(),
|
artifact.type(),
|
||||||
str(release.release_artifact_token),
|
token,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __parse_forgejo_release_id__(self, release_response: str) -> int:
|
def __parse_forgejo_release_id__(self, release_response: str) -> int:
|
||||||
|
|
|
@ -224,14 +224,15 @@ class ArtifactDeploymentApi:
|
||||||
self.execution_api = ExecutionApi()
|
self.execution_api = ExecutionApi()
|
||||||
|
|
||||||
def create_forgejo_release(self, api_endpoint_url: str, tag: str, token: str):
|
def create_forgejo_release(self, api_endpoint_url: str, tag: str, token: str):
|
||||||
sanitized_command = (
|
command = (
|
||||||
f'curl -X "POST" "{api_endpoint_url}" '
|
f'curl -X "POST" "{api_endpoint_url}" '
|
||||||
+ ' -H "accept: application/json" -H "Content-Type: application/json"'
|
+ ' -H "accept: application/json" -H "Content-Type: application/json"'
|
||||||
+ f' -d \'{{ "body": "Provides files for release {tag}", "tag_name": "{tag}"}}\''
|
+ f' -d \'{{ "body": "Provides files for release {tag}", "tag_name": "{tag}"}}\''
|
||||||
) # noqa: E501
|
) # noqa: E501
|
||||||
command = sanitized_command + f'-H "Authorization: token {token}"'
|
print(command + ' -H "Authorization: token xxxx"')
|
||||||
return self.execution_api.execute_secure(
|
return self.execution_api.execute_secure(
|
||||||
command=command, sanitized_command=sanitized_command
|
command=command + f' -H "Authorization: token {token}"',
|
||||||
|
sanitized_command=command + ' -H "Authorization: token xxxx"',
|
||||||
)
|
)
|
||||||
|
|
||||||
def add_asset_to_release(
|
def add_asset_to_release(
|
||||||
|
@ -241,15 +242,16 @@ class ArtifactDeploymentApi:
|
||||||
attachment_type: str,
|
attachment_type: str,
|
||||||
token: str,
|
token: str,
|
||||||
):
|
):
|
||||||
return self.execution_api.execute_secure(
|
command = (
|
||||||
f'curl -X "POST" "{api_endpoint_url}"'
|
f'curl -X "POST" "{api_endpoint_url}"'
|
||||||
+ f'-H "accept: application/json" -H "Authorization: token {token}" '
|
|
||||||
+ '-H "Content-Type: multipart/form-data" '
|
|
||||||
+ f'-F "attachment=@{attachment};type={attachment_type}"',
|
|
||||||
sanitized_command=f'curl -X "POST" "{api_endpoint_url}" '
|
|
||||||
+ ' -H "accept: application/json"'
|
+ ' -H "accept: application/json"'
|
||||||
+ ' -H "Content-Type: multipart/form-data"'
|
+ ' -H "Content-Type: multipart/form-data"'
|
||||||
+ f'-F "attachment=@{attachment};type={attachment_type}"',
|
+ f' -F "attachment=@{attachment};type={attachment_type}"'
|
||||||
|
) # noqa: E501
|
||||||
|
print(command + ' -H "Authorization: token xxxx"')
|
||||||
|
return self.execution_api.execute_secure(
|
||||||
|
command=command + f' -H "Authorization: token {token}"',
|
||||||
|
sanitized_command=command + ' -H "Authorization: token xxxx"',
|
||||||
)
|
)
|
||||||
|
|
||||||
def calculate_sha256(self, path: Path):
|
def calculate_sha256(self, path: Path):
|
||||||
|
|
Loading…
Reference in a new issue