TUN-7392: Ignore release checksum upload if asset already uploaded

This commit is contained in:
Devin Carr 2023-04-26 13:46:35 -07:00
parent 76391434c2
commit 50a0c44cee
1 changed files with 7 additions and 3 deletions

View File

@ -170,12 +170,14 @@ def upload_asset(release, filepath, filename, release_version, kv_account_id, na
uploaded = False
for asset in assets:
if asset.name == filename:
logging.info("asset already uploaded, skipping upload")
uploaded = True
break
if not uploaded:
release.upload_asset(filepath, name=filename)
if uploaded:
logging.info("asset already uploaded, skipping upload")
return
release.upload_asset(filepath, name=filename)
# check and extract if the file is a tar and gzipped file (as is the case with the macos builds)
binary_path = filepath
@ -195,6 +197,7 @@ def upload_asset(release, filepath, filename, release_version, kv_account_id, na
pkg_hash = get_sha256(binary_path)
send_hash(pkg_hash, filename, release_version, kv_account_id, namespace_id, kv_api_token)
def move_asset(filepath, filename):
# create the artifacts directory if it doesn't exist
artifact_path = os.path.join(os.getcwd(), 'artifacts')
if not os.path.isdir(artifact_path):
@ -225,6 +228,7 @@ def main():
binary_path = os.path.join(args.path, filename)
upload_asset(release, binary_path, filename, args.release_version, args.kv_account_id, args.namespace_id,
args.kv_api_token)
move_asset(binary_path, filename)
else:
upload_asset(release, args.path, args.name, args.release_version, args.kv_account_id, args.namespace_id,
args.kv_api_token)