Skip to content

Commit 3ab2b6e

Browse files
fix: Artifact publishing script (#18275)
1 parent 8e56ed1 commit 3ab2b6e

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

packages/contracts-bedrock/scripts/ops/publish-artifacts.sh

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fi
2828
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
2929
CONTRACTS_DIR="$SCRIPT_DIR/../.."
3030
DEPLOY_BUCKET="oplabs-contract-artifacts"
31+
BUCKET_URL="https://storage.googleapis.com/$DEPLOY_BUCKET"
3132

3233
cd "$CONTRACTS_DIR"
3334

@@ -60,19 +61,23 @@ fi
6061

6162
checksum=$(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+
6370
echoerr "> Checksum: $checksum"
6471
echoerr "> Checking for existing artifacts..."
6572

6673
if [ "$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
7379
fi
7480

75-
upload_url_gz="https://storage.googleapis.com/$DEPLOY_BUCKET/artifacts-v1-$checksum.tar.gz"
7681
exists_gz=$(curl -s -o /dev/null --fail -LI "$upload_url_gz" || echo "fail")
7782

7883
if [ "$exists_gz" != "fail" ] && [ "$FORCE" = false ]; then
@@ -93,23 +98,21 @@ rm -f COMMIT
9398
commit=$(git rev-parse HEAD)
9499
echo "$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

97110
if [ "$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
141144
else
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"
154150
fi
155151

156152
echoerr "> Done."
157153

158-
echoerr "> Uploading artifacts to GCS..."
154+
echoerr "> Uploading artifacts to $BUCKET_URL..."
159155

160156
# Force single-stream upload to improve reliability
161157
gcloud config set storage/parallel_composite_upload_enabled False

0 commit comments

Comments
 (0)