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+
70+ upload_artifacts=(" $archive_name_gz " )
71+
6372echoerr " > Checksum: $checksum "
6473echoerr " > Checking for existing artifacts..."
6574
6675if [ " $HAS_ZSTD " = true ]; then
67- upload_url_zst=" https://storage.googleapis.com/$DEPLOY_BUCKET /artifacts-v1-$checksum .tar.zst"
6876 exists_zst=$( curl -s -o /dev/null --fail -LI " $upload_url_zst " || echo " fail" )
6977 if [ " $exists_zst " != " fail" ] && [ " $FORCE " = false ]; then
7078 echoerr " > Existing artifacts found (.tar.zst), nothing to do. Use --force to overwrite."
7179 exit 0
7280 fi
81+
82+ upload_artifacts+=(" $archive_name_zst " )
7383fi
7484
75- upload_url_gz=" https://storage.googleapis.com/$DEPLOY_BUCKET /artifacts-v1-$checksum .tar.gz"
7685exists_gz=$( curl -s -o /dev/null --fail -LI " $upload_url_gz " || echo " fail" )
7786
7887if [ " $exists_gz " != " fail" ] && [ " $FORCE " = false ]; then
@@ -93,23 +102,21 @@ rm -f COMMIT
93102commit=$( git rev-parse HEAD)
94103echo " $commit " > COMMIT
95104
105+ tar_args=(" artifacts" " forge-artifacts" " COMMIT" )
106+ if [ -d " cache" ]; then
107+ tar_args+=(" cache" )
108+ echoerr " > Including cache directory in archive"
109+ else
110+ echoerr " > Cache directory not found, excluding from archive"
111+ fi
112+
96113
97114if [ " $HAS_ZSTD " = true ]; then
98115 echoerr " > Compressing artifacts (.tar.gz and .tar.zst)..."
99116
100117 # Create intermediate tar file first for reliable compression
101118 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"
119+ " $tar " -cf " $temp_tar " " ${tar_args[@]} "
113120
114121 gzip -9 < " $temp_tar " > " $archive_name_gz " &
115122 gz_pid=$!
@@ -140,33 +147,25 @@ if [ "$HAS_ZSTD" = true ]; then
140147 fi
141148else
142149 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 "
150+
151+ " $tar " -czf " $archive_name_gz " " ${tar_args[@]} "
152152 du -sh " $archive_name_gz " | awk ' {$1=$1};1' # trim leading whitespace
153153 echoerr " > Created .tar.gz archive"
154154fi
155155
156156echoerr " > Done."
157157
158- echoerr " > Uploading artifacts to GCS ..."
158+ echoerr " > Uploading artifacts to $BUCKET_URL ..."
159159
160160# Force single-stream upload to improve reliability
161161gcloud config set storage/parallel_composite_upload_enabled False
162- if [ " $HAS_ZSTD " = true ]; then
163- gcloud --verbosity=" info" storage cp " $archive_name_gz " " $archive_name_zst " " gs://$DEPLOY_BUCKET /"
164- echoerr " > Uploaded to: $upload_url_gz "
165- echoerr " > Uploaded to: $upload_url_zst "
166- else
167- gcloud --verbosity=" info" storage cp " $archive_name_gz " " gs://$DEPLOY_BUCKET /$archive_name_gz "
168- echoerr " > Uploaded to: $upload_url_gz "
169- fi
162+
163+ # Upload the artifacts
164+ gcloud --verbosity=" info" storage cp " ${upload_artifacts[@]} " " gs://$DEPLOY_BUCKET /"
165+
166+ for artifact_name in " ${upload_artifacts[@]} " ; do
167+ echoerr " > Uploaded to: $BUCKET_URL /$artifact_name "
168+ done
170169
171170echoerr " > Done."
172171
0 commit comments