From 6cd4d907ba24496387fd1b618852f6ef020317e4 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Wed, 22 Jun 2022 16:48:17 -0700 Subject: [PATCH] upload-release: Only copy full releases to zulip-server-latest.tar.gz. `zulip-server-6.0-pre0.tar.gz` should not be copied to `zulip-server-latest.tar.gz`. --- tools/upload-release | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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 = ""