wip: prepare ataching artifacts
This commit is contained in:
parent
caaf804fd3
commit
bfcdcbb78a
2 changed files with 23 additions and 6 deletions
|
@ -69,11 +69,29 @@ class ReleaseService:
|
||||||
release.release_artifact_token,
|
release.release_artifact_token,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
artifacts_to_attach = []
|
||||||
for artifact_path in release.release_artifacts:
|
for artifact_path in release.release_artifacts:
|
||||||
self.artifact_deployment_api.calculate_checksums(artifact_path)
|
self.artifact_deployment_api.calculate_checksums(artifact_path)
|
||||||
|
# TODO: make api more explizit to have the path calculation & decision which shas to take clear
|
||||||
|
artifacts_to_attach += [{
|
||||||
|
"path": artifact_path,
|
||||||
|
# TODO: it will not always be a jar file -> move type to release input-side.
|
||||||
|
"type": "application/x-java-archive",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": f"{artifact_path}.sha256",
|
||||||
|
"type": "text/plain",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": f"{artifact_path}.sha512",
|
||||||
|
"type": "text/plain",
|
||||||
|
}]
|
||||||
|
|
||||||
|
# TODO: use structure created above
|
||||||
|
for artifact in artifacts_to_attach:
|
||||||
self.artifact_deployment_api.add_asset_to_release(
|
self.artifact_deployment_api.add_asset_to_release(
|
||||||
"todo",
|
release.forgejo_release_asset_api_endpoint(release_id),
|
||||||
release_id,
|
|
||||||
"todo",
|
"todo",
|
||||||
"todo",
|
"todo",
|
||||||
release.release_artifact_token,
|
release.release_artifact_token,
|
||||||
|
|
|
@ -231,18 +231,17 @@ class ArtifactDeploymentApi:
|
||||||
|
|
||||||
def add_asset_to_release(
|
def add_asset_to_release(
|
||||||
self,
|
self,
|
||||||
target_url: str,
|
api_endpoint_url: str,
|
||||||
release_id: str,
|
|
||||||
attachment: str,
|
attachment: str,
|
||||||
attachment_type: str,
|
attachment_type: str,
|
||||||
token: str,
|
token: str,
|
||||||
):
|
):
|
||||||
return self.execution_api.execute_secure(
|
return self.execution_api.execute_secure(
|
||||||
f'curl -X "POST" "{target_url}/{release_id}/assets" ' # {target_url}/{release_id}/assets move to Domain
|
f'curl -X "POST" "{api_endpoint_url}" '
|
||||||
+ f'-H "accept: application/json" -H "Authorization: token {token}" '
|
+ f'-H "accept: application/json" -H "Authorization: token {token}" '
|
||||||
+ '-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}"',
|
||||||
sanitized_command=f'curl -X "POST" "{target_url}/{release_id}/assets" ' # see above
|
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}"',
|
||||||
|
|
Loading…
Reference in a new issue