2828SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
2929CONTRACTS_DIR=" $SCRIPT_DIR /../.."
3030DEPLOY_BUCKET=" oplabs-contract-artifacts"
31+ BUCKET_URL=" https://storage.googleapis.com/$DEPLOY_BUCKET "
3132
3233cd " $CONTRACTS_DIR "
3334
6061
6162checksum=$( bash scripts/ops/calculate-checksum.sh)
6263
64+ archive_name_gz=" artifacts-v1-$checksum .tar.gz"
65+ archive_name_zst=" artifacts-v1-$checksum .tar.zst"
66+
67+ upload_url_gz=" $BUCKET_URL /$archive_name_gz "
68+ upload_url_zst=" $BUCKET_URL /$archive_name_zst "
69+
6370echoerr " > Checksum: $checksum "
6471echoerr " > Checking for existing artifacts..."
6572
6673if [ " $HAS_ZSTD " = true ]; then
67- upload_url_zst=" https://storage.googleapis.com/$DEPLOY_BUCKET /artifacts-v1-$checksum .tar.zst"
6874 exists_zst=$( curl -s -o /dev/null --fail -LI " $upload_url_zst " || echo " fail" )
6975 if [ " $exists_zst " != " fail" ] && [ " $FORCE " = false ]; then
7076 echoerr " > Existing artifacts found (.tar.zst), nothing to do. Use --force to overwrite."
7177 exit 0
7278 fi
7379fi
7480
75- upload_url_gz=" https://storage.googleapis.com/$DEPLOY_BUCKET /artifacts-v1-$checksum .tar.gz"
7681exists_gz=$( curl -s -o /dev/null --fail -LI " $upload_url_gz " || echo " fail" )
7782
7883if [ " $exists_gz " != " fail" ] && [ " $FORCE " = false ]; then
@@ -93,23 +98,21 @@ rm -f COMMIT
9398commit=$( git rev-parse HEAD)
9499echo " $commit " > COMMIT
95100
101+ tar_args=(" artifacts" " forge-artifacts" " COMMIT" )
102+ if [ -d " cache" ]; then
103+ tar_args+=(" cache" )
104+ echoerr " > Including cache directory in archive"
105+ else
106+ echoerr " > Cache directory not found, excluding from archive"
107+ fi
108+
96109
97110if [ " $HAS_ZSTD " = true ]; then
98111 echoerr " > Compressing artifacts (.tar.gz and .tar.zst)..."
99112
100113 # Create intermediate tar file first for reliable compression
101114 temp_tar=" artifacts-v1-$checksum .tar"
102- tar_args=" artifacts forge-artifacts COMMIT"
103- if [ -d " cache" ]; then
104- tar_args=" $tar_args cache"
105- echoerr " > Including cache directory in archive"
106- else
107- echoerr " > Cache directory not found, excluding from archive"
108- fi
109- " $tar " -cf " $temp_tar " " $tar_args "
110-
111- archive_name_gz=" artifacts-v1-$checksum .tar.gz"
112- archive_name_zst=" artifacts-v1-$checksum .tar.zst"
115+ " $tar " -cf " $temp_tar " " ${tar_args[@]} "
113116
114117 gzip -9 < " $temp_tar " > " $archive_name_gz " &
115118 gz_pid=$!
@@ -140,22 +143,15 @@ if [ "$HAS_ZSTD" = true ]; then
140143 fi
141144else
142145 echoerr " > Compressing artifacts (.tar.gz)..."
143- archive_name_gz=" artifacts-v1-$checksum .tar.gz"
144- tar_args=" artifacts forge-artifacts COMMIT"
145- if [ -d " cache" ]; then
146- tar_args=" $tar_args cache"
147- echoerr " > Including cache directory in archive"
148- else
149- echoerr " > Cache directory not found, excluding from archive"
150- fi
151- " $tar " -czf " $archive_name_gz " " $tar_args "
146+
147+ " $tar " -czf " $archive_name_gz " " ${tar_args[@]} "
152148 du -sh " $archive_name_gz " | awk ' {$1=$1};1' # trim leading whitespace
153149 echoerr " > Created .tar.gz archive"
154150fi
155151
156152echoerr " > Done."
157153
158- echoerr " > Uploading artifacts to GCS ..."
154+ echoerr " > Uploading artifacts to $BUCKET_URL ..."
159155
160156# Force single-stream upload to improve reliability
161157gcloud config set storage/parallel_composite_upload_enabled False
0 commit comments