|
|
@@ -41,6 +41,8 @@ runs:
|
|
|
GH_TOKEN: ${{ inputs.github_token }}
|
|
|
TARGET_REPO: "${{ github.repository }}"
|
|
|
run: |
|
|
|
+ set -euo pipefail
|
|
|
+
|
|
|
# Archive, Split, and Upload Cache
|
|
|
if [ "${{ inputs.debug }}" = "true" ]; then set -x; fi
|
|
|
|
|
|
@@ -110,30 +112,48 @@ runs:
|
|
|
upload_with_retry() {
|
|
|
local file=$1
|
|
|
local max_attempts=3
|
|
|
+ local timeout_duration="10m"
|
|
|
+
|
|
|
+ if [ "$TAG_NAME" != "bazel-cache" ]; then
|
|
|
+ timeout_duration="30m"
|
|
|
+ fi
|
|
|
+
|
|
|
for ((i=1; i<=max_attempts; i++)); do
|
|
|
echo " Attempt $i for $file..."
|
|
|
|
|
|
if [ "${{ inputs.debug }}" = "true" ]; then
|
|
|
- if timeout 10m gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO"; then
|
|
|
+ if timeout "$timeout_duration" gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO"; then
|
|
|
echo " Successfully uploaded $file"
|
|
|
return 0
|
|
|
fi
|
|
|
else
|
|
|
- if timeout 10m gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO" > /dev/null 2>&1; then
|
|
|
+ if timeout "$timeout_duration" gh release upload "$TAG_NAME" "$file" --clobber --repo "$TARGET_REPO" > /dev/null 2>&1; then
|
|
|
echo " Successfully uploaded $file"
|
|
|
return 0
|
|
|
fi
|
|
|
fi
|
|
|
|
|
|
- echo " ⚠ Attempt $i failed or timed out. Retrying..."
|
|
|
- sleep 5
|
|
|
+ echo " ⚠ Attempt $i failed or timed out after $timeout_duration. Retrying..."
|
|
|
+ if [ "$i" -lt "$max_attempts" ]; then
|
|
|
+ sleep 5
|
|
|
+ fi
|
|
|
done
|
|
|
return 1
|
|
|
}
|
|
|
|
|
|
- if [ "$FILE_SIZE" -gt "$MAX_SIZE" ]; then
|
|
|
- echo "⚠ File > 2GB. Splitting..."
|
|
|
- split -b 1500M -a 2 "$FILENAME" "${FILENAME}.part"
|
|
|
+ chunk_size="1500M"
|
|
|
+ split_required=false
|
|
|
+
|
|
|
+ if [ "$TAG_NAME" != "bazel-cache" ]; then
|
|
|
+ chunk_size="250M"
|
|
|
+ split_required=true
|
|
|
+ elif [ "$FILE_SIZE" -gt "$MAX_SIZE" ]; then
|
|
|
+ split_required=true
|
|
|
+ fi
|
|
|
+
|
|
|
+ if [ "$split_required" = "true" ]; then
|
|
|
+ echo "⚠ Splitting into ${chunk_size} chunks..."
|
|
|
+ split -b "$chunk_size" -a 2 "$FILENAME" "${FILENAME}.part"
|
|
|
for part in "${FILENAME}".part*; do
|
|
|
echo "Uploading $part..."
|
|
|
if ! upload_with_retry "$part"; then
|