Skip to content

fix(upload): Add delays and improve error handling #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tools/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ function github_release_asset_upload(){ # github_release_asset_upload <repo-path
function github_release_asset_delete(){ # github_release_asset_delete <repo-path> <release-asset-id>
local repo_path="$1"
local release_asset_id="$2"
local res=$(curl -s -k -o /dev/null -w "%{http_code}" -X DELETE -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases/assets/$release_asset_id")
if [ "$res" -eq 204 ]; then echo 1; else echo 0; fi
local res
local return_code
res=$(curl -s -k -o /dev/null -w "%{http_code}" -X DELETE -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw+json" "https://api.github.com/repos/$repo_path/releases/assets/$release_asset_id")
return_code=$?
if [ "$res" -eq 204 ] && [ "$return_code" -eq 0 ] ; then echo 1; else echo 0; fi
}


Expand Down
20 changes: 15 additions & 5 deletions tools/push-to-arduino.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,22 @@ if [ $AR_HAS_COMMIT == "0" ] || [ $LIBS_HAS_ASSET == "0" ]; then
fi
fi

sleep 5
echo "Creating asset '$LIBS_ZIP_FILENAME'..."

mv -f "dist/esp32-arduino-libs.zip" "dist/$LIBS_ZIP_FILENAME"

LIBS_ASSET_ID=`github_release_asset_upload "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_ZIP_FILENAME" "dist/$LIBS_ZIP_FILENAME"`
if [ -z "$LIBS_ASSET_ID" ]; then
echo "ERROR: Failed to upload asset '$LIBS_ZIP_FILENAME'"
exit 1
echo "ERROR: Failed to upload asset '$LIBS_ZIP_FILENAME. Retrying..."
LIBS_ASSET_ID=`github_release_asset_upload "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_ZIP_FILENAME" "dist/$LIBS_ZIP_FILENAME"`
if [ -z "$LIBS_ASSET_ID" ]; then
echo "ERROR: Failed to upload asset '$LIBS_ZIP_FILENAME'"
exit 1
fi
fi

echo "Finished uploading asset '$LIBS_ZIP_FILENAME'. Asset ID: $LIBS_ASSET_ID"
sleep 5

# Calculate the local file checksum and size
local_checksum=$(sha256sum "dist/$LIBS_ZIP_FILENAME" | awk '{print $1}')
Expand Down Expand Up @@ -108,8 +114,12 @@ if [ $AR_HAS_COMMIT == "0" ] || [ $LIBS_HAS_ASSET == "0" ]; then

JSON_ASSET_ID=`github_release_asset_upload "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_JSON_FILENAME" "$AR_OUT/package_esp32_index.template.json"`
if [ -z "$JSON_ASSET_ID" ]; then
echo "ERROR: Failed to upload asset '$LIBS_JSON_FILENAME'"
exit 1
echo "ERROR: Failed to upload asset '$LIBS_JSON_FILENAME'. Retrying..."
JSON_ASSET_ID=`github_release_asset_upload "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_JSON_FILENAME" "$AR_OUT/package_esp32_index.template.json"`
if [ -z "$JSON_ASSET_ID" ]; then
echo "ERROR: Failed to upload asset '$LIBS_JSON_FILENAME'"
exit 1
fi
fi
fi

Expand Down
Loading