Skip to content

Commit

Permalink
publish_release.py: inform CDN origins about new archive files (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdarwin authored Mar 12, 2024
1 parent 074a23c commit 774a12a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__/
.env
68 changes: 66 additions & 2 deletions publish_release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env -S python3 -u
#
# Downloads snapshots from artifactory, renames them, confirms the sha hash,
# and then uploads the files back to artifactory.
Expand Down Expand Up @@ -38,6 +38,11 @@
import re, os, sys
import json
from pathlib import Path
import subprocess
import pathlib

# run: pip3 install python-dotenv
from dotenv import load_dotenv

jfrogURL = "https://boostorg.jfrog.io/artifactory/"

Expand Down Expand Up @@ -105,7 +110,8 @@ def uploadJFROGFile(sourceFileName, destRepo):


#####
parser = OptionParser()
usage = "usage: %prog [options] boost_version # Example: %prog 1_85_0"
parser = OptionParser(usage=usage)
parser.add_option(
"-b", "--beta", default=None, type="int", help="build a beta release", dest="beta"
)
Expand Down Expand Up @@ -254,3 +260,61 @@ def uploadJFROGFile(sourceFileName, destRepo):
"export AWS_PROFILE=%s;rclone sync --transfers 16 --checksum %s %s"
% (profile, archivePathLocal, archivePathRemote)
)

###############################################################################
#
# Inform CDN origins about uploaded files
#
###############################################################################

# The CDN origins are set to update on a slow schedule, once per day.
# To refresh them more quickly, upload a text file with information.
#
if not options.dryrun:
try:
load_dotenv()
SSH_USER = os.getenv("SSH_USER")
except:
SSH_USER = "mclow"

list_of_uploaded_files = []
for s in suffixes:
list_of_uploaded_files.append(destRepo + actualName + s)
list_of_uploaded_files.append(destRepo + actualName + s + ".json")

source_file_list = "/tmp/boostarchivesinfo/filelist.txt"
source_file_list_dir = os.path.dirname(source_file_list)

# create dir
Path(source_file_list_dir).mkdir(mode=0o777, parents=True, exist_ok=True)

# if source_file_list existed previously, remove it
if os.path.isfile(source_file_list):
pathlib.Path(source_file_list).unlink()

# populate source_file_list
with open(source_file_list, "w") as f:
for file in list_of_uploaded_files:
f.write(file)
f.write("\n")

for origin in ["brorigin1.cpp.al", "brorigin2.cpp.al"]:
try:
result = subprocess.run(
f'ssh {SSH_USER}@{origin} "mkdir -p {source_file_list_dir}; chmod 777 {source_file_list_dir}"',
shell=True,
check=True,
capture_output=True,
text=True,
)
result = subprocess.run(
f"scp -p {source_file_list} {SSH_USER}@{origin}:{source_file_list}",
shell=True,
check=True,
capture_output=True,
text=True,
)
except:
print(
"SSH to the CDN origin servers failed. Check your SSH keys, and set SSH_USER=_username_ in an .env file in the same directory as publish_release.py."
)

0 comments on commit 774a12a

Please sign in to comment.