use a different tmpdir for every Bazel binary
@@ -1042,8 +1042,6 @@ def sha256_hexdigest(filename):
def try_publish_binaries(build_number, expected_generation):
- tmpdir = tempfile.mkdtemp()
- try:
now = datetime.datetime.now()
info = {
"build_number": build_number,
@@ -1052,6 +1050,8 @@ def try_publish_binaries(build_number, expected_generation):
"platforms": {}
}
for platform in supported_platforms():
+ tmpdir = tempfile.mkdtemp()
+ try:
bazel_binary_path = download_bazel_binary(tmpdir, platform)
execute_command([gsutil_command(), "cp", "-a", "public-read", bazel_binary_path,
bazelci_builds_upload_url(platform, build_number)])
@@ -1059,7 +1059,10 @@ def try_publish_binaries(build_number, expected_generation):
"url": bazelci_builds_download_url(platform, build_number),
"sha256": sha256_hexdigest(bazel_binary_path),
}
-
+ finally:
+ shutil.rmtree(tmpdir)
+ tmpdir = tempfile.mkdtemp()
+ try:
info_file = os.path.join(tmpdir, "info.json")
with open(info_file, mode="w", encoding="utf-8") as fp:
json.dump(info, fp, indent=2, sort_keys=True)
