Skip to content

Commit 7e8c510

Browse files
committed
Merge branch 'ci/update_version'
2 parents 372ba6a + 8e13e27 commit 7e8c510

File tree

2 files changed

+139
-7
lines changed

2 files changed

+139
-7
lines changed

.github/scripts/on-release.sh

Lines changed: 134 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ if [ -n "${VENDOR}" ]; then
5454
echo "Setting packager: $VENDOR"
5555
fi
5656

57+
function update_version {
58+
local tag=$1
59+
local major
60+
local minor
61+
local patch
62+
63+
# Extract major, minor, and patch from the tag
64+
# We need to make sure to remove the "v" prefix from the tag and any characters after the patch version
65+
tag=$(echo "$tag" | sed 's/^v//g' | sed 's/-.*//g')
66+
major=$(echo "$tag" | cut -d. -f1)
67+
minor=$(echo "$tag" | cut -d. -f2)
68+
patch=$(echo "$tag" | cut -d. -f3)
69+
70+
echo "Major: $major, Minor: $minor, Patch: $patch"
71+
72+
"${SCRIPTS_DIR}/update-version.sh" "$major" "$minor" "$patch"
73+
}
74+
5775
function get_file_size {
5876
local file="$1"
5977
if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -199,8 +217,28 @@ set -e
199217
##
200218

201219
mkdir -p "$OUTPUT_DIR"
202-
PKG_DIR="$OUTPUT_DIR/$PACKAGE_NAME"
220+
PKG_DIR="${OUTPUT_DIR:?}/$PACKAGE_NAME"
203221
PACKAGE_ZIP="$PACKAGE_NAME.zip"
222+
PACKAGE_XZ="$PACKAGE_NAME.tar.xz"
223+
LIBS_ZIP="$PACKAGE_NAME-libs.zip"
224+
LIBS_XZ="$PACKAGE_NAME-libs.tar.xz"
225+
226+
echo "Updating version..."
227+
update_version "$RELEASE_TAG"
228+
git config --global github.user "github-actions[bot]"
229+
git config --global user.name "github-actions[bot]"
230+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
231+
git add .
232+
233+
# We should only commit if there are changes
234+
need_update_commit=true
235+
if git diff --cached --quiet; then
236+
echo "Version already updated"
237+
need_update_commit=false
238+
else
239+
echo "Creating version update commit..."
240+
git commit -m "change(version): Update core version to $RELEASE_TAG"
241+
fi
204242

205243
echo "Updating submodules ..."
206244
git -C "$GITHUB_WORKSPACE" submodule update --init --recursive > /dev/null 2>&1
@@ -283,7 +321,7 @@ echo \#define ARDUINO_ESP32_GIT_DESC "$(git -C "$GITHUB_WORKSPACE" describe --ta
283321
echo \#define ARDUINO_ESP32_RELEASE_"$ver_define" >> "$PKG_DIR/cores/esp32/core_version.h"
284322
echo \#define ARDUINO_ESP32_RELEASE \""$ver_define"\" >> "$PKG_DIR/cores/esp32/core_version.h"
285323

286-
# Compress package folder
324+
# Compress ZIP package folder
287325
echo "Creating ZIP ..."
288326
pushd "$OUTPUT_DIR" >/dev/null
289327
zip -qr "$PACKAGE_ZIP" "$PACKAGE_NAME"
@@ -293,22 +331,100 @@ if [ $? -ne 0 ]; then
293331
fi
294332

295333
# Calculate SHA-256
296-
echo "Calculating SHA sum ..."
297-
PACKAGE_PATH="$OUTPUT_DIR/$PACKAGE_ZIP"
334+
echo "Calculating ZIP SHA sum ..."
335+
PACKAGE_PATH="${OUTPUT_DIR:?}/$PACKAGE_ZIP"
298336
PACKAGE_SHA=$(shasum -a 256 "$PACKAGE_ZIP" | cut -f 1 -d ' ')
299337
PACKAGE_SIZE=$(get_file_size "$PACKAGE_ZIP")
300338
popd >/dev/null
301-
rm -rf "$PKG_DIR"
302339
echo "'$PACKAGE_ZIP' Created! Size: $PACKAGE_SIZE, SHA-256: $PACKAGE_SHA"
303340
echo
304341

305-
# Upload package to release page
306-
echo "Uploading package to release page ..."
342+
# Compress XZ package folder
343+
echo "Creating XZ ..."
344+
pushd "$OUTPUT_DIR" >/dev/null
345+
tar -cJf "$PACKAGE_XZ" "$PACKAGE_NAME"
346+
if [ $? -ne 0 ]; then
347+
echo "ERROR: Failed to create $PACKAGE_XZ ($?)"
348+
exit 1
349+
fi
350+
351+
# Calculate SHA-256
352+
echo "Calculating XZ SHA sum ..."
353+
PACKAGE_XZ_PATH="${OUTPUT_DIR:?}/$PACKAGE_XZ"
354+
PACKAGE_XZ_SHA=$(shasum -a 256 "$PACKAGE_XZ" | cut -f 1 -d ' ')
355+
PACKAGE_XZ_SIZE=$(get_file_size "$PACKAGE_XZ")
356+
popd >/dev/null
357+
echo "'$PACKAGE_XZ' Created! Size: $PACKAGE_XZ_SIZE, SHA-256: $PACKAGE_XZ_SHA"
358+
echo
359+
360+
# Upload ZIP package to release page
361+
echo "Uploading ZIP package to release page ..."
307362
PACKAGE_URL=$(git_safe_upload_asset "$PACKAGE_PATH")
308363
echo "Package Uploaded"
309364
echo "Download URL: $PACKAGE_URL"
310365
echo
311366

367+
# Upload XZ package to release page
368+
echo "Uploading XZ package to release page ..."
369+
PACKAGE_XZ_URL=$(git_safe_upload_asset "$PACKAGE_XZ_PATH")
370+
echo "Package Uploaded"
371+
echo "Download URL: $PACKAGE_XZ_URL"
372+
echo
373+
374+
# Remove package folder
375+
rm -rf "$PKG_DIR"
376+
377+
# Copy Libs from lib-builder to release in ZIP and XZ
378+
379+
libs_url=$(cat "$PACKAGE_JSON_TEMPLATE" | jq -r ".packages[0].tools[] | select(.name == \"esp32-arduino-libs\") | .systems[0].url")
380+
libs_sha=$(cat "$PACKAGE_JSON_TEMPLATE" | jq -r ".packages[0].tools[] | select(.name == \"esp32-arduino-libs\") | .systems[0].checksum" | sed 's/^SHA-256://')
381+
libs_size=$(cat "$PACKAGE_JSON_TEMPLATE" | jq -r ".packages[0].tools[] | select(.name == \"esp32-arduino-libs\") | .systems[0].size")
382+
echo "Downloading libs from lib-builder ..."
383+
echo "URL: $libs_url"
384+
echo "Expected SHA: $libs_sha"
385+
echo "Expected Size: $libs_size"
386+
echo
387+
388+
echo "Downloading libs from lib-builder ..."
389+
curl -L -o "$OUTPUT_DIR/$LIBS_ZIP" "$libs_url"
390+
391+
# Check SHA and Size
392+
zip_sha=$(sha256sum "$OUTPUT_DIR/$LIBS_ZIP" | awk '{print $1}')
393+
zip_size=$(stat -c%s "$OUTPUT_DIR/$LIBS_ZIP")
394+
echo "Downloaded SHA: $zip_sha"
395+
echo "Downloaded Size: $zip_size"
396+
if [ "$zip_sha" != "$libs_sha" ] || [ "$zip_size" != "$libs_size" ]; then
397+
echo "ERROR: ZIP SHA and Size do not match"
398+
exit 1
399+
fi
400+
401+
# Extract ZIP
402+
403+
echo "Repacking libs to XZ ..."
404+
unzip -q "$OUTPUT_DIR/$LIBS_ZIP" -d "$OUTPUT_DIR"
405+
pushd "$OUTPUT_DIR" >/dev/null
406+
tar -cJf "$LIBS_XZ" "esp32-arduino-libs"
407+
popd >/dev/null
408+
409+
# Upload ZIP and XZ libs to release page
410+
411+
echo "Uploading ZIP libs to release page ..."
412+
LIBS_ZIP_URL=$(git_safe_upload_asset "$OUTPUT_DIR/$LIBS_ZIP")
413+
echo "ZIP libs Uploaded"
414+
echo "Download URL: $LIBS_ZIP_URL"
415+
echo
416+
417+
echo "Uploading XZ libs to release page ..."
418+
LIBS_XZ_URL=$(git_safe_upload_asset "$OUTPUT_DIR/$LIBS_XZ")
419+
echo "XZ libs Uploaded"
420+
echo "Download URL: $LIBS_XZ_URL"
421+
echo
422+
423+
# Clean up
424+
rm -rf "${OUTPUT_DIR:?}/esp32-arduino-libs"
425+
rm -rf "${OUTPUT_DIR:?}/$LIBS_ZIP"
426+
rm -rf "${OUTPUT_DIR:?}/$LIBS_XZ"
427+
312428
##
313429
## TEMP WORKAROUND FOR RV32 LONG PATH ON WINDOWS
314430
##
@@ -469,6 +585,17 @@ if [ "$RELEASE_PRE" == "false" ]; then
469585
echo
470586
fi
471587

588+
if [ "$need_update_commit" == "true" ]; then
589+
echo "Pushing version update commit..."
590+
git push
591+
new_tag_commit=$(git rev-parse HEAD)
592+
echo "New commit: $new_tag_commit"
593+
594+
echo "Moving tag $RELEASE_TAG to $new_tag_commit..."
595+
git tag -f "$RELEASE_TAG" "$new_tag_commit"
596+
git push --force origin "$RELEASE_TAG"
597+
fi
598+
472599
set +e
473600

474601
##

.github/scripts/update-version.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ echo "Updating issue template..."
3838
cat .github/ISSUE_TEMPLATE/Issue-report.yml | \
3939
sed "s/.*\- latest master .*/ - latest master \(checkout manually\)\\n - v$ESP_ARDUINO_VERSION/g" > __issue-report.yml && mv __issue-report.yml .github/ISSUE_TEMPLATE/Issue-report.yml
4040

41+
echo "Updating GitLab variables..."
42+
cat .gitlab/workflows/common.yml | \
43+
sed "s/ESP_IDF_VERSION:.*/ESP_IDF_VERSION: \"$ESP_IDF_VERSION\"/g" | \
44+
sed "s/ESP_ARDUINO_VERSION:.*/ESP_ARDUINO_VERSION: \"$ESP_ARDUINO_VERSION\"/g" > .gitlab/workflows/__common.yml && mv .gitlab/workflows/__common.yml .gitlab/workflows/common.yml
45+
4146
echo "Updating platform.txt..."
4247
cat platform.txt | sed "s/version=.*/version=$ESP_ARDUINO_VERSION/g" > __platform.txt && mv __platform.txt platform.txt
4348

0 commit comments

Comments
 (0)