diff --git a/tools/upload-release b/tools/upload-release index 30fd910250..37f54590c1 100755 --- a/tools/upload-release +++ b/tools/upload-release @@ -2,9 +2,10 @@ import argparse import hashlib import os +import re import sys import tempfile -from typing import IO, Dict +from typing import IO, Dict, List, cast sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) from scripts.lib.setup_path import setup_path @@ -71,7 +72,7 @@ for obj_summary in bucket.objects.filter(Prefix="server/zulip-server-"): file_hashes[filename] = metadata["sha256sum"] -ordered_filenames = natsorted(file_hashes.keys(), reverse=True) +ordered_filenames = cast(List[str], natsorted(file_hashes.keys(), reverse=True)) assert ordered_filenames[0] == "zulip-server-latest.tar.gz" print(f"Uploading {new_basename}..") @@ -86,14 +87,19 @@ bucket.upload_file( ExtraArgs=extra, ) -if ordered_filenames[1] == new_basename: - print("Copying to zulip-server-latest.tar.gz..") +if ( + next(name for name in ordered_filenames if re.match(r"^zulip-server-(\d+\.\d+)\.tar.gz$", name)) + == new_basename +): + print("This looks like the most recent full release; copying to zulip-server-latest.tar.gz..") bucket.copy( CopySource={"Bucket": bucket.name, "Key": f"server/{new_basename}"}, Key="server/zulip-server-latest.tar.gz", ExtraArgs=extra, ) file_hashes["zulip-server-latest.tar.gz"] = file_hashes[new_basename] +else: + print("Not copying to zulip-server-latest.tar.gz!") print("Updating SHA256SUMS.txt..") contents = ""