From 7e753a736c3a0e7146f85ec933ac9daf332c4f87 Mon Sep 17 00:00:00 2001 From: Jeff Cheng <83052155+jeffreyc-splunk@users.noreply.github.com> Date: Thu, 19 Jan 2023 11:25:26 -0500 Subject: [PATCH] Add --not-latest option to release script (#2490) --- .../packaging/release/helpers/release_args.py | 11 ++++++++ .../packaging/release/helpers/util.py | 25 +++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/internal/buildscripts/packaging/release/helpers/release_args.py b/internal/buildscripts/packaging/release/helpers/release_args.py index 007fd29f20e..fed9dc82f69 100644 --- a/internal/buildscripts/packaging/release/helpers/release_args.py +++ b/internal/buildscripts/packaging/release/helpers/release_args.py @@ -137,6 +137,17 @@ def get_args_and_asset(): Required if the --path option is not specified. """, ) + parser.add_argument( + "--not-latest", + action="store_true", + default=False, + required=False, + help=""" + Only applicable if the --path option is specified for a MSI file. + By default, the latest.txt file on dl.signalfx.com is automatically updated with the version of the MSI. + If uploading an older version of the MSI, specify this option to skip this step. + """, + ) parser.add_argument( "--timeout", type=int, diff --git a/internal/buildscripts/packaging/release/helpers/util.py b/internal/buildscripts/packaging/release/helpers/util.py index da313ee0adf..c908b98576b 100755 --- a/internal/buildscripts/packaging/release/helpers/util.py +++ b/internal/buildscripts/packaging/release/helpers/util.py @@ -286,17 +286,20 @@ def release_msi_to_s3(asset, args): s3_path = f"{S3_MSI_BASE_DIR}/{args.stage}/{asset.name}" upload_file_to_s3(msi_path, s3_path, force=args.force) - with tempfile.TemporaryDirectory() as tmpdir: - latest_txt = os.path.join(tmpdir, "latest.txt") - match = re.match(f"^{PACKAGE_NAME}-(\d+\.\d+\.\d+(\.\d+)?)-amd64.msi$", asset.name) - assert match, f"Failed to get version from '{asset.name}'!" - msi_version = match.group(1) - with open(latest_txt, "w") as fd: - fd.write(msi_version) - s3_latest_path = f"{S3_MSI_BASE_DIR}/{args.stage}/latest.txt" - print(f"Updating {S3_BUCKET}/{s3_latest_path} for version '{msi_version}' ...") - upload_file_to_s3(latest_txt, s3_latest_path, force=True) - invalidate_cloudfront([s3_path, s3_latest_path]) + + s3_latest_path = f"{S3_MSI_BASE_DIR}/{args.stage}/latest.txt" + if not args.not_latest: + with tempfile.TemporaryDirectory() as tmpdir: + latest_txt = os.path.join(tmpdir, "latest.txt") + match = re.match(f"^{PACKAGE_NAME}-(\d+\.\d+\.\d+(\.\d+)?)-amd64.msi$", asset.name) + assert match, f"Failed to get version from '{asset.name}'!" + msi_version = match.group(1) + with open(latest_txt, "w") as fd: + fd.write(msi_version) + print(f"Updating {S3_BUCKET}/{s3_latest_path} for version '{msi_version}' ...") + upload_file_to_s3(latest_txt, s3_latest_path, force=True) + + invalidate_cloudfront([s3_path, s3_latest_path]) def release_installers_to_s3(force=False): if not force: