Skip to content

Commit

Permalink
Add --not-latest option to release script (open-telemetry#2490)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyc-splunk committed Jan 19, 2023
1 parent d43da70 commit 7e753a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
11 changes: 11 additions & 0 deletions internal/buildscripts/packaging/release/helpers/release_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 14 additions & 11 deletions internal/buildscripts/packaging/release/helpers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7e753a7

Please sign in to comment.