Skip to content

Commit

Permalink
Merge pull request #140 from greenbone/improve-signing
Browse files Browse the repository at this point in the history
Small improvements
  • Loading branch information
bjoernricks authored Jun 24, 2021
2 parents 2bc29b4 + 30d8a63 commit 296e39d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 10 additions & 10 deletions pontos/release/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def update_version(
def upload_assets(
username: str,
token: str,
pathnames: List[str],
file_paths: List[Path],
github_json: Dict,
path: Path,
requests_module: requests,
Expand All @@ -256,30 +256,30 @@ def upload_assets(
Arguments:
username: The GitHub username to use for the upload
token: That username's GitHub token
pathnames: List of paths to asset files
file_paths: List of paths to asset files
github_json: The github dictionary, containing relevant information
for the uplaod
for the upload
path: the python pathlib.Path module
requests_module: the python request module
Returns:
True on success, false else
"""
info(f"Uploading assets: {pathnames}")
info(f"Uploading assets: {[str(p) for p in file_paths]}")

asset_url = github_json['upload_url'].replace('{?name,label}', '')
paths = [path(f'{p}.asc') for p in pathnames]
paths = [path(f'{str(p)}.asc') for p in file_paths]

headers = {
'Accept': 'application/vnd.github.v3+json',
'content-type': 'application/octet-stream',
}
auth = (username, token)

for path in paths:
to_upload = path.read_bytes()
for file_path in paths:
to_upload = file_path.read_bytes()
resp = requests_module.post(
f"{asset_url}?name={path.name}",
f"{asset_url}?name={file_path.name}",
headers=headers,
auth=auth,
data=to_upload,
Expand All @@ -288,11 +288,11 @@ def upload_assets(
if resp.status_code != 201:
error(
f"Wrong response status {resp.status_code}"
f" while uploading {path.name}"
f" while uploading {file_path.name}"
)
out(json.dumps(resp.text, indent=4, sort_keys=True))
return False
else:
ok(f"uploaded: {path.name}")
ok(f"Uploaded: {file_path.name}")

return True
3 changes: 2 additions & 1 deletion pontos/release/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ def sign(
info(f"Signing {file_path}")

shell_cmd_runner(
f"gpg --default-key {signing_key} --detach-sign --armor {file_path}"
f"gpg --default-key {signing_key} --yes --detach-sign --armor "
f"{file_path}"
)

return upload_assets(
Expand Down

0 comments on commit 296e39d

Please sign in to comment.