From d3b1cfd52aad4e9045ff2637a8717eec2ad3a426 Mon Sep 17 00:00:00 2001 From: flakey5 <73616808+flakey5@users.noreply.github.com> Date: Sun, 28 Jan 2024 10:57:54 -0800 Subject: [PATCH] ansible: promote release assets from staging r2 bucket Reference #3602 --- .../www-standalone/tools/promote/_resha.sh | 29 +++++++++++++++++++ ansible/www-standalone/tools/promote/settings | 3 +- .../tools/promote/upload_to_cloudflare.sh | 14 +++++---- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/ansible/www-standalone/tools/promote/_resha.sh b/ansible/www-standalone/tools/promote/_resha.sh index 0ce9acb65..2ee77eddf 100755 --- a/ansible/www-standalone/tools/promote/_resha.sh +++ b/ansible/www-standalone/tools/promote/_resha.sh @@ -6,6 +6,11 @@ site=$1 dstdir=$2 version=$3 +if [ "X${site}" == "X" ]; then + echo "site argument not provided" + exit 1 +fi + if [ "X${dstdir}" == "X" ]; then echo "dstdir argument not provided" exit 1 @@ -16,6 +21,26 @@ if [ "X${version}" == "X" ]; then exit 1 fi +if [ -z ${dist_rootdir+x} ]; then + echo "\$dist_rootdir is not set" + exit 1 +fi + +if [ -z ${staging_bucket+x} ]; then + echo "\$staging_bucket is not set" + exit 1 +fi + +if [ -z ${cloudflare_endpoint+x} ]; then + echo "\$cloudflare_endpoint is not set" + exit 1 +fi + +if [ -z ${cloudflare_profile+x} ]; then + echo "\$cloudflare_profile is not set" + exit 1 +fi + (cd "${dstdir}/${version}" && shasum -a256 $(ls node* openssl* iojs* win-*/* x64/* 2> /dev/null) > SHASUMS256.txt) || exit 1 if [[ $version =~ ^v[0] ]]; then (cd "${dstdir}/${version}" && shasum $(ls node* openssl* x64/* 2> /dev/null) > SHASUMS.txt) || exit 1 @@ -25,3 +50,7 @@ nodejs-dist-indexer --dist $dstdir --indexjson ${dstdir}/index.json --indextab find "${dstdir}/${version}" -type f -exec chmod 644 '{}' \; find "${dstdir}/${version}" -type d -exec chmod 755 '{}' \; +relativedir=${dstdir/$dist_rootdir/"$site/"} +aws s3 cp ${dstdir}/index.json $staging_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile +aws s3 cp ${dstdir}/index.tab $staging_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile +aws s3 cp ${dstdir}/${version}/SHASUMS256.txt $staging_bucket/$relativedir/${version}/SHASUM256.txt --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile diff --git a/ansible/www-standalone/tools/promote/settings b/ansible/www-standalone/tools/promote/settings index 17ddd827a..24342c1ce 100755 --- a/ansible/www-standalone/tools/promote/settings +++ b/ansible/www-standalone/tools/promote/settings @@ -39,4 +39,5 @@ chakracore_release_dirmatch=.* cloudflare_endpoint=https://07be8d2fbc940503ca1be344714cb0d1.r2.cloudflarestorage.com cloudflare_profile=worker -destination_bucket=s3://dist-prod +staging_bucket=s3://dist-staging +dist_bucket=s3://dist-prod diff --git a/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh b/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh index dc99ab182..d91438b9a 100755 --- a/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh +++ b/ansible/www-standalone/tools/promote/upload_to_cloudflare.sh @@ -22,8 +22,12 @@ if [ -z ${dist_rootdir+x} ]; then echo "\$dist_rootdir is not set" exit 1 fi -if [ -z ${destination_bucket+x} ]; then - echo "\$destination_bucket is not set" +if [ -z ${staging_bucket+x} ]; then + echo "\$staging_bucket is not set" + exit 1 +fi +if [ -z ${dist_bucket+x} ]; then + echo "\$dist_bucket is not set" exit 1 fi if [ -z ${cloudflare_endpoint+x} ]; then @@ -38,6 +42,6 @@ fi relativedir=${dstdir/$dist_rootdir/"$site/"} tmpversion=$2 -aws s3 cp $dstdir/$tmpversion/ $destination_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --recursive --no-follow-symlinks -aws s3 cp $dstdir/index.json $destination_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile -aws s3 cp $dstdir/index.tab $destination_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile +aws s3 cp $staging_bucket/$relativedir/$tmpversion/ $dist_bucket/$relativedir/$tmpversion/ --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile --recursive --no-follow-symlinks +aws s3 cp $staging_bucket/$relativedir/index.json $dist_bucket/$relativedir/index.json --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile +aws s3 cp $staging_bucket/$relativedir/index.tab $dist_bucket/$relativedir/index.tab --endpoint-url=$cloudflare_endpoint --profile $cloudflare_profile