@@ -107,6 +107,13 @@ function git_safe_upload_asset {
107107 fi
108108
109109 up_size=$( echo " $upload_res " | jq -r ' .size' )
110+
111+ # Check if up_size is a valid integer (not null or empty)
112+ if [ " $up_size " = " null" ] || [ -z " $up_size " ] || ! [ " $up_size " -eq " $up_size " ] 2> /dev/null; then
113+ >&2 echo " ERROR: Could not get uploaded file size from API response. Response: $upload_res "
114+ return 1
115+ fi
116+
110117 if [ " $up_size " -ne " $size " ]; then
111118 >&2 echo " ERROR: Uploaded size does not match! $up_size != $size "
112119 # git_delete_asset
@@ -217,8 +224,11 @@ set -e
217224# #
218225
219226mkdir -p " $OUTPUT_DIR "
220- PKG_DIR=" $OUTPUT_DIR /$PACKAGE_NAME "
227+ PKG_DIR=" ${ OUTPUT_DIR:? } /$PACKAGE_NAME "
221228PACKAGE_ZIP=" $PACKAGE_NAME .zip"
229+ PACKAGE_XZ=" $PACKAGE_NAME .tar.xz"
230+ LIBS_ZIP=" $PACKAGE_NAME -libs.zip"
231+ LIBS_XZ=" $PACKAGE_NAME -libs.tar.xz"
222232
223233echo " Updating version..."
224234update_version " $RELEASE_TAG "
@@ -318,7 +328,7 @@ echo \#define ARDUINO_ESP32_GIT_DESC "$(git -C "$GITHUB_WORKSPACE" describe --ta
318328echo \# define ARDUINO_ESP32_RELEASE_" $ver_define " >> " $PKG_DIR /cores/esp32/core_version.h"
319329echo \# define ARDUINO_ESP32_RELEASE \" " $ver_define " \" >> " $PKG_DIR /cores/esp32/core_version.h"
320330
321- # Compress package folder
331+ # Compress ZIP package folder
322332echo " Creating ZIP ..."
323333pushd " $OUTPUT_DIR " > /dev/null
324334zip -qr " $PACKAGE_ZIP " " $PACKAGE_NAME "
@@ -328,22 +338,99 @@ if [ $? -ne 0 ]; then
328338fi
329339
330340# Calculate SHA-256
331- echo " Calculating SHA sum ..."
332- PACKAGE_PATH=" $OUTPUT_DIR /$PACKAGE_ZIP "
341+ echo " Calculating ZIP SHA sum ..."
342+ PACKAGE_PATH=" ${ OUTPUT_DIR:? } /$PACKAGE_ZIP "
333343PACKAGE_SHA=$( shasum -a 256 " $PACKAGE_ZIP " | cut -f 1 -d ' ' )
334344PACKAGE_SIZE=$( get_file_size " $PACKAGE_ZIP " )
335345popd > /dev/null
336- rm -rf " $PKG_DIR "
337346echo " '$PACKAGE_ZIP ' Created! Size: $PACKAGE_SIZE , SHA-256: $PACKAGE_SHA "
338347echo
339348
340- # Upload package to release page
341- echo " Uploading package to release page ..."
349+ # Upload ZIP package to release page
350+ echo " Uploading ZIP package to release page ..."
351+ PACKAGE_URL=$( git_safe_upload_asset " $PACKAGE_PATH " )
352+ echo " Package Uploaded"
353+ echo " Download URL: $PACKAGE_URL "
354+ echo
355+
356+ # Compress XZ package folder
357+ echo " Creating XZ ..."
358+ pushd " $OUTPUT_DIR " > /dev/null
359+ tar -cJf " $PACKAGE_XZ " " $PACKAGE_NAME "
360+ if [ $? -ne 0 ]; then
361+ echo " ERROR: Failed to create $PACKAGE_XZ ($? )"
362+ exit 1
363+ fi
364+
365+ # Calculate SHA-256
366+ echo " Calculating XZ SHA sum ..."
367+ PACKAGE_XZ_PATH=" ${OUTPUT_DIR:? } /$PACKAGE_XZ "
368+ PACKAGE_XZ_SHA=$( shasum -a 256 " $PACKAGE_XZ " | cut -f 1 -d ' ' )
369+ PACKAGE_XZ_SIZE=$( get_file_size " $PACKAGE_XZ " )
370+ popd > /dev/null
371+ echo " '$PACKAGE_XZ ' Created! Size: $PACKAGE_XZ_SIZE , SHA-256: $PACKAGE_XZ_SHA "
372+ echo
373+
374+ # Upload ZIP package to release page
375+ echo " Uploading ZIP package to release page ..."
342376PACKAGE_URL=$( git_safe_upload_asset " $PACKAGE_PATH " )
343377echo " Package Uploaded"
344378echo " Download URL: $PACKAGE_URL "
345379echo
346380
381+ # Upload XZ package to release page
382+ echo " Uploading XZ package to release page ..."
383+ PACKAGE_XZ_URL=$( git_safe_upload_asset " $PACKAGE_XZ_PATH " )
384+ echo " Package Uploaded"
385+ echo " Download URL: $PACKAGE_XZ_URL "
386+ echo
387+
388+ # Remove package folder
389+ rm -rf " $PKG_DIR "
390+
391+ # Copy Libs from lib-builder to release in ZIP and XZ
392+
393+ echo " Downloading libs from lib-builder ..."
394+ libs_url=$( cat " $PACKAGE_JSON_TEMPLATE " | jq -r " .packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[0].url" )
395+ libs_sha=$( cat " $PACKAGE_JSON_TEMPLATE " | jq -r " .packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[0].checksum" )
396+ libs_size=$( cat " $PACKAGE_JSON_TEMPLATE " | jq -r " .packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[0].size" )
397+
398+ curl -L -o " $OUTPUT_DIR /$LIBS_ZIP " " $libs_url "
399+
400+ # Check SHA and Size
401+ zip_sha=$( sha256sum " $OUTPUT_DIR /$LIBS_ZIP " | awk ' {print $1}' )
402+ zip_size=$( stat -c%s " $OUTPUT_DIR /$LIBS_ZIP " )
403+ if [ " $zip_sha " != " $libs_sha " ] || [ " $zip_size " != " $libs_size " ]; then
404+ echo " ERROR: ZIP SHA and Size do not match"
405+ exit 1
406+ fi
407+
408+ # Extract ZIP
409+
410+ echo " Repacking libs to XZ ..."
411+ mkdir -p " ${OUTPUT_DIR:? } /tmp-libs"
412+ unzip " $OUTPUT_DIR /$LIBS_ZIP " -d " $OUTPUT_DIR /tmp-libs"
413+ tar -cJf " $OUTPUT_DIR /$LIBS_XZ " " $OUTPUT_DIR /tmp-libs"
414+
415+ # Upload ZIP and XZ libs to release page
416+
417+ echo " Uploading ZIP libs to release page ..."
418+ LIBS_ZIP_URL=$( git_safe_upload_asset " $OUTPUT_DIR /$LIBS_ZIP " )
419+ echo " ZIP libs Uploaded"
420+ echo " Download URL: $LIBS_ZIP_URL "
421+ echo
422+
423+ echo " Uploading XZ libs to release page ..."
424+ LIBS_XZ_URL=$( git_safe_upload_asset " $OUTPUT_DIR /$LIBS_XZ " )
425+ echo " XZ libs Uploaded"
426+ echo " Download URL: $LIBS_XZ_URL "
427+ echo
428+
429+ # Clean up
430+ rm -rf " ${OUTPUT_DIR:? } /tmp-libs"
431+ rm -rf " ${OUTPUT_DIR:? } /$LIBS_ZIP "
432+ rm -rf " ${OUTPUT_DIR:? } /$LIBS_XZ "
433+
347434# #
348435# # TEMP WORKAROUND FOR RV32 LONG PATH ON WINDOWS
349436# #
0 commit comments