@@ -54,6 +54,30 @@ if [ -n "${VENDOR}" ]; then
5454 echo " Setting packager: $VENDOR "
5555fi
5656
57+ function update_version {
58+ set -e
59+ set -o pipefail
60+
61+ local tag=$1
62+ local major
63+ local minor
64+ local patch
65+
66+ # Extract major, minor, and patch from the tag
67+ # We need to make sure to remove the "v" prefix from the tag and any characters after the patch version
68+ tag=$( echo " $tag " | sed ' s/^v//g' | sed ' s/-.*//g' )
69+ major=$( echo " $tag " | cut -d. -f1)
70+ minor=$( echo " $tag " | cut -d. -f2)
71+ patch=$( echo " $tag " | cut -d. -f3 | sed ' s/[^0-9].*//' ) # Remove non-numeric suffixes like RC1, alpha, beta
72+
73+ echo " Major: $major , Minor: $minor , Patch: $patch "
74+
75+ " ${SCRIPTS_DIR} /update-version.sh" " $major " " $minor " " $patch "
76+
77+ set +e
78+ set +o pipefail
79+ }
80+
5781function get_file_size {
5882 local file=" $1 "
5983 if [[ " $OSTYPE " == " darwin" * ]]; then
@@ -199,8 +223,31 @@ set -e
199223# #
200224
201225mkdir -p " $OUTPUT_DIR "
202- PKG_DIR=" $OUTPUT_DIR /$PACKAGE_NAME "
226+ PKG_DIR=" ${ OUTPUT_DIR:? } /$PACKAGE_NAME "
203227PACKAGE_ZIP=" $PACKAGE_NAME .zip"
228+ PACKAGE_XZ=" $PACKAGE_NAME .tar.xz"
229+ LIBS_ZIP=" $PACKAGE_NAME -libs.zip"
230+ LIBS_XZ=" $PACKAGE_NAME -libs.tar.xz"
231+
232+ echo " Updating version..."
233+ if ! update_version " $RELEASE_TAG " ; then
234+ echo " ERROR: update_version failed!"
235+ exit 1
236+ fi
237+ git config --global github.user " github-actions[bot]"
238+ git config --global user.name " github-actions[bot]"
239+ git config --global user.email " 41898282+github-actions[bot]@users.noreply.github.com"
240+ git add .
241+
242+ # We should only commit if there are changes
243+ need_update_commit=true
244+ if git diff --cached --quiet; then
245+ echo " Version already updated"
246+ need_update_commit=false
247+ else
248+ echo " Creating version update commit..."
249+ git commit -m " change(version): Update core version to $RELEASE_TAG "
250+ fi
204251
205252echo " Updating submodules ..."
206253git -C " $GITHUB_WORKSPACE " submodule update --init --recursive > /dev/null 2>&1
@@ -283,7 +330,7 @@ echo \#define ARDUINO_ESP32_GIT_DESC "$(git -C "$GITHUB_WORKSPACE" describe --ta
283330echo \# define ARDUINO_ESP32_RELEASE_" $ver_define " >> " $PKG_DIR /cores/esp32/core_version.h"
284331echo \# define ARDUINO_ESP32_RELEASE \" " $ver_define " \" >> " $PKG_DIR /cores/esp32/core_version.h"
285332
286- # Compress package folder
333+ # Compress ZIP package folder
287334echo " Creating ZIP ..."
288335pushd " $OUTPUT_DIR " > /dev/null
289336zip -qr " $PACKAGE_ZIP " " $PACKAGE_NAME "
@@ -293,22 +340,112 @@ if [ $? -ne 0 ]; then
293340fi
294341
295342# Calculate SHA-256
296- echo " Calculating SHA sum ..."
297- PACKAGE_PATH=" $OUTPUT_DIR /$PACKAGE_ZIP "
343+ echo " Calculating ZIP SHA sum ..."
344+ PACKAGE_PATH=" ${ OUTPUT_DIR:? } /$PACKAGE_ZIP "
298345PACKAGE_SHA=$( shasum -a 256 " $PACKAGE_ZIP " | cut -f 1 -d ' ' )
299346PACKAGE_SIZE=$( get_file_size " $PACKAGE_ZIP " )
300347popd > /dev/null
301- rm -rf " $PKG_DIR "
302348echo " '$PACKAGE_ZIP ' Created! Size: $PACKAGE_SIZE , SHA-256: $PACKAGE_SHA "
303349echo
304350
305- # Upload package to release page
306- echo " Uploading package to release page ..."
351+ # Compress XZ package folder
352+ echo " Creating XZ ..."
353+ pushd " $OUTPUT_DIR " > /dev/null
354+ tar -cJf " $PACKAGE_XZ " " $PACKAGE_NAME "
355+ if [ $? -ne 0 ]; then
356+ echo " ERROR: Failed to create $PACKAGE_XZ ($? )"
357+ exit 1
358+ fi
359+
360+ # Calculate SHA-256
361+ echo " Calculating XZ SHA sum ..."
362+ PACKAGE_XZ_PATH=" ${OUTPUT_DIR:? } /$PACKAGE_XZ "
363+ PACKAGE_XZ_SHA=$( shasum -a 256 " $PACKAGE_XZ " | cut -f 1 -d ' ' )
364+ PACKAGE_XZ_SIZE=$( get_file_size " $PACKAGE_XZ " )
365+ popd > /dev/null
366+ echo " '$PACKAGE_XZ ' Created! Size: $PACKAGE_XZ_SIZE , SHA-256: $PACKAGE_XZ_SHA "
367+ echo
368+
369+ # Upload ZIP package to release page
370+ echo " Uploading ZIP package to release page ..."
307371PACKAGE_URL=$( git_safe_upload_asset " $PACKAGE_PATH " )
308372echo " Package Uploaded"
309373echo " Download URL: $PACKAGE_URL "
310374echo
311375
376+ # Upload XZ package to release page
377+ echo " Uploading XZ package to release page ..."
378+ PACKAGE_XZ_URL=$( git_safe_upload_asset " $PACKAGE_XZ_PATH " )
379+ echo " Package Uploaded"
380+ echo " Download URL: $PACKAGE_XZ_URL "
381+ echo
382+
383+ # Remove package folder
384+ rm -rf " $PKG_DIR "
385+
386+ # Copy Libs from lib-builder to release in ZIP and XZ
387+
388+ libs_url=$( cat " $PACKAGE_JSON_TEMPLATE " | jq -r " .packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[0].url" )
389+ libs_sha=$( cat " $PACKAGE_JSON_TEMPLATE " | jq -r " .packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[0].checksum" | sed ' s/^SHA-256://' )
390+ libs_size=$( cat " $PACKAGE_JSON_TEMPLATE " | jq -r " .packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[0].size" )
391+ echo " Downloading libs from lib-builder ..."
392+ echo " URL: $libs_url "
393+ echo " Expected SHA: $libs_sha "
394+ echo " Expected Size: $libs_size "
395+ echo
396+
397+ echo " Downloading libs from lib-builder ..."
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+ echo " Downloaded SHA: $zip_sha "
404+ echo " Downloaded Size: $zip_size "
405+ if [ " $zip_sha " != " $libs_sha " ] || [ " $zip_size " != " $libs_size " ]; then
406+ echo " ERROR: ZIP SHA and Size do not match"
407+ exit 1
408+ fi
409+
410+ # Extract ZIP
411+
412+ echo " Repacking libs to XZ ..."
413+ unzip -q " $OUTPUT_DIR /$LIBS_ZIP " -d " $OUTPUT_DIR "
414+ pushd " $OUTPUT_DIR " > /dev/null
415+ tar -cJf " $LIBS_XZ " " esp32-arduino-libs"
416+ popd > /dev/null
417+
418+ # Upload ZIP and XZ libs to release page
419+
420+ echo " Uploading ZIP libs to release page ..."
421+ LIBS_ZIP_URL=$( git_safe_upload_asset " $OUTPUT_DIR /$LIBS_ZIP " )
422+ echo " ZIP libs Uploaded"
423+ echo " Download URL: $LIBS_ZIP_URL "
424+ echo
425+
426+ echo " Uploading XZ libs to release page ..."
427+ LIBS_XZ_URL=$( git_safe_upload_asset " $OUTPUT_DIR /$LIBS_XZ " )
428+ echo " XZ libs Uploaded"
429+ echo " Download URL: $LIBS_XZ_URL "
430+ echo
431+
432+ # Update libs URLs in JSON template
433+ echo " Updating libs URLs in JSON template ..."
434+
435+ # Update all libs URLs in the JSON template
436+ libs_jq_arg=" (.packages[0].tools[] | select(.name == \" esp32-arduino-libs\" ) | .systems[].url) = \" $LIBS_ZIP_URL \" "
437+
438+ cat " $PACKAGE_JSON_TEMPLATE " | jq " $libs_jq_arg " > " $OUTPUT_DIR /package-libs-updated.json"
439+ PACKAGE_JSON_TEMPLATE=" $OUTPUT_DIR /package-libs-updated.json"
440+
441+ echo " Libs URLs updated in JSON template"
442+ echo
443+
444+ # Clean up
445+ rm -rf " ${OUTPUT_DIR:? } /esp32-arduino-libs"
446+ rm -rf " ${OUTPUT_DIR:? } /$LIBS_ZIP "
447+ rm -rf " ${OUTPUT_DIR:? } /$LIBS_XZ "
448+
312449# #
313450# # TEMP WORKAROUND FOR RV32 LONG PATH ON WINDOWS
314451# #
@@ -469,6 +606,17 @@ if [ "$RELEASE_PRE" == "false" ]; then
469606 echo
470607fi
471608
609+ if [ " $need_update_commit " == " true" ]; then
610+ echo " Pushing version update commit..."
611+ git push
612+ new_tag_commit=$( git rev-parse HEAD)
613+ echo " New commit: $new_tag_commit "
614+
615+ echo " Moving tag $RELEASE_TAG to $new_tag_commit ..."
616+ git tag -f " $RELEASE_TAG " " $new_tag_commit "
617+ git push --force origin " $RELEASE_TAG "
618+ fi
619+
472620set +e
473621
474622# #
0 commit comments