Skip to content

Commit 8445a86

Browse files
committed
fix
1 parent 3404bea commit 8445a86

File tree

2 files changed

+62
-63
lines changed

2 files changed

+62
-63
lines changed

.github/workflows/cron_build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ jobs:
136136
with:
137137
name: esp32-arduino-libs-${{ env.libs_branch }}
138138
path: dist/esp32-arduino-libs.zip
139+
compression-level: 0
139140

140141
- name: Push changes
142+
#if: ${{ github.repository_owner == 'espressif' }}
141143
env:
142144
GITHUB_TOKEN: ${{ secrets.PUSH_TOKEN }}
143145
GIT_AUTHOR_EMAIL: ${{ secrets.PUSH_EMAIL }}

tools/push-to-arduino.sh

+60-63
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ git config --global user.email "[email protected]"
2020
# esp32-arduino-libs
2121
#
2222

23-
if [ $LIBS_HAS_ASSET == "0" ] && [ $AR_HAS_COMMIT == "0" ]; then
24-
cd "$AR_ROOT"
25-
mkdir -p dist
23+
LIBS_ZIP_FILENAME="esp32-arduino-libs-$LIBS_VERSION.zip"
24+
LIBS_JSON_FILENAME="package-$LIBS_VERSION.json"
25+
IDF_LIBS_ZIP_URL="https://github.com/$AR_LIBS_REPO/releases/download/$LIBS_RELEASE_TAG/$LIBS_ZIP_FILENAME"
26+
IDF_LIBS_JSON_URL="https://github.com/$AR_LIBS_REPO/releases/download/$LIBS_RELEASE_TAG/$LIBS_JSON_FILENAME"
2627

27-
# check if the release exists
28-
if [ $LIBS_HAS_RELEASE == "0" ]; then
29-
echo "Release for tag \"$LIBS_RELEASE_TAG\" not found. Please create the release first."
30-
exit 1
31-
fi
28+
if [ $AR_HAS_COMMIT == "0" ]; then
29+
if [ $LIBS_HAS_ASSET == "0" ]; then
30+
cd "$AR_ROOT"
31+
mkdir -p dist
3232

33-
LIBS_ZIP_FILENAME="esp32-arduino-libs-$LIBS_VERSION.zip"
34-
LIBS_JSON_FILENAME="package-$LIBS_VERSION.json"
33+
# check if the release exists
34+
if [ $LIBS_HAS_RELEASE == "0" ]; then
35+
echo "Release for tag \"$LIBS_RELEASE_TAG\" not found. Please create the release first."
36+
exit 1
37+
fi
3538

36-
# create asset if necessary
37-
if [ "$LIBS_HAS_ASSET" == "0" ]; then
3839
echo "Creating asset '$LIBS_ZIP_FILENAME'..."
3940

4041
mv -f "dist/esp32-arduino-libs.zip" "dist/$LIBS_ZIP_FILENAME"
@@ -43,77 +44,73 @@ if [ $LIBS_HAS_ASSET == "0" ] && [ $AR_HAS_COMMIT == "0" ]; then
4344
echo "ERROR: Failed to upload asset '$LIBS_ZIP_FILENAME'"
4445
exit 1
4546
fi
46-
fi
4747

48-
# Calculate the local file checksum and size
49-
local_checksum=$(sha256sum "dist/$LIBS_ZIP_FILENAME" | awk '{print $1}')
50-
local_size=$(stat -c%s "dist/$LIBS_ZIP_FILENAME")
51-
IDF_LIBS_DL_URL="https://github.com/$AR_LIBS_REPO/releases/download/$LIBS_RELEASE_TAG/$LIBS_ZIP_FILENAME"
48+
# Calculate the local file checksum and size
49+
local_checksum=$(sha256sum "dist/$LIBS_ZIP_FILENAME" | awk '{print $1}')
50+
local_size=$(stat -c%s "dist/$LIBS_ZIP_FILENAME")
5251

53-
echo "Downloading asset '$LIBS_ZIP_FILENAME' and checking integrity..."
52+
echo "Downloading asset '$LIBS_ZIP_FILENAME' and checking integrity..."
5453

55-
# Download the file
56-
remote_file="remote-$LIBS_ZIP_FILENAME"
57-
curl -s -L -o "$remote_file" "$IDF_LIBS_DL_URL"
54+
# Download the file
55+
remote_file="remote-$LIBS_ZIP_FILENAME"
56+
curl -s -L -o "$remote_file" "$IDF_LIBS_ZIP_URL"
5857

59-
# Check if the download was successful
60-
if [ $? -ne 0 ]; then
61-
echo "Error downloading file from $IDF_LIBS_DL_URL. Retrying..."
62-
rm -f "$remote_file"
63-
curl -s -L -o "$remote_file" "$IDF_LIBS_DL_URL"
58+
# Check if the download was successful
6459
if [ $? -ne 0 ]; then
65-
echo "Error downloading file from $IDF_LIBS_DL_URL"
60+
echo "Error downloading file from $IDF_LIBS_ZIP_URL"
6661
exit 1
6762
fi
68-
fi
6963

70-
# Calculate the remote file checksum and size
71-
remote_checksum=$(sha256sum "$remote_file" | awk '{print $1}')
72-
remote_size=$(stat -c%s "$remote_file")
64+
# Calculate the remote file checksum and size
65+
remote_checksum=$(sha256sum "$remote_file" | awk '{print $1}')
66+
remote_size=$(stat -c%s "$remote_file")
67+
68+
echo "Local: $local_size bytes, $local_checksum"
69+
echo "Remote: $remote_size bytes, $remote_checksum"
7370

74-
echo "Local: $local_size bytes, $local_checksum"
75-
echo "Remote: $remote_size bytes, $remote_checksum"
71+
# Check if the checksums match
72+
if [ "$local_checksum" != "$remote_checksum" ]; then
73+
echo "Checksum mismatch for downloaded file"
74+
echo "Deleting asset and exiting..."
75+
if [ `github_release_asset_delete "$AR_LIBS_REPO" "$LIBS_ASSET_ID"` == "0" ]; then
76+
echo "ERROR: Failed to delete asset '$LIBS_ZIP_FILENAME'"
77+
fi
78+
exit 1
79+
fi
7680

77-
# Check if the checksums match
78-
if [ "$local_checksum" != "$remote_checksum" ]; then
79-
echo "Checksum mismatch for downloaded file. Retrying..."
81+
# Clean up the downloaded file
8082
rm "$remote_file"
8183

82-
curl -s -L -o "$remote_file" "$IDF_LIBS_DL_URL"
83-
if [ $? -ne 0 ]; then
84-
echo "Error downloading file from $IDF_LIBS_DL_URL"
84+
# Print the results
85+
echo "Tool: esp32-arduino-libs"
86+
echo "Version: $LIBS_VERSION"
87+
echo "URL: $IDF_LIBS_ZIP_URL"
88+
echo "File: $LIBS_ZIP_FILENAME"
89+
echo "Size: $local_size bytes"
90+
echo "SHA-256: $local_checksum"
91+
echo "JSON: $AR_OUT/package_esp32_index.template.json"
92+
cd "$AR_ROOT"
93+
python3 tools/add_sdk_json.py -j "$AR_OUT/package_esp32_index.template.json" -n "esp32-arduino-libs" -v "$LIBS_VERSION" -u "$IDF_LIBS_ZIP_URL" -f "$LIBS_ZIP_FILENAME" -s "$local_size" -c "$local_checksum"
94+
if [ $? -ne 0 ]; then exit 1; fi
95+
96+
if [ `github_release_asset_upload "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_JSON_FILENAME" "$AR_OUT/package_esp32_index.template.json"` == ""]; then
97+
echo "ERROR: Failed to upload asset '$LIBS_JSON_FILENAME'"
8598
exit 1
8699
fi
100+
else
101+
echo "Asset '$LIBS_ZIP_FILENAME' already exists. Downloading JSON file..."
87102

88-
remote_checksum=$(sha256sum "$remote_file" | awk '{print $1}')
89-
if [ "$local_checksum" != "$remote_checksum" ]; then
90-
echo "Checksum mismatch for downloaded file after retry"
91-
echo "Deleting asset and exiting..."
103+
if [ `github_release_asset_id "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_JSON_FILENAME"` == "" ]; then
104+
echo "ERROR: JSON file '$LIBS_JSON_FILENAME' not found. Deleting asset '$LIBS_ZIP_FILENAME' and exiting..."
92105
if [ `github_release_asset_delete "$AR_LIBS_REPO" "$LIBS_ASSET_ID"` == "0" ]; then
93106
echo "ERROR: Failed to delete asset '$LIBS_ZIP_FILENAME'"
94107
fi
95108
exit 1
96109
fi
97-
fi
98110

99-
# Clean up the downloaded file
100-
rm "$remote_file"
101-
102-
# Print the results
103-
echo "Tool: esp32-arduino-libs"
104-
echo "Version: $LIBS_VERSION"
105-
echo "URL: $IDF_LIBS_DL_URL"
106-
echo "File: $LIBS_ZIP_FILENAME"
107-
echo "Size: $local_size bytes"
108-
echo "SHA-256: $local_checksum"
109-
echo "JSON: $AR_OUT/package_esp32_index.template.json"
110-
cd "$AR_ROOT"
111-
python3 tools/add_sdk_json.py -j "$AR_OUT/package_esp32_index.template.json" -n "esp32-arduino-libs" -v "$LIBS_VERSION" -u "$IDF_LIBS_DL_URL" -f "$LIBS_ZIP_FILENAME" -s "$local_size" -c "$local_checksum"
112-
if [ $? -ne 0 ]; then exit 1; fi
113-
114-
if [ `github_release_asset_upload "$AR_LIBS_REPO" "$LIBS_RELEASE_ID" "$LIBS_JSON_FILENAME" "$AR_OUT/package_esp32_index.template.json"` == ""]; then
115-
echo "ERROR: Failed to upload asset '$LIBS_JSON_FILENAME'"
116-
exit 1
111+
cd "$AR_ROOT"
112+
mkdir -p $AR_OUT
113+
curl -s -L -o "$AR_OUT/package_esp32_index.template.json" "$IDF_LIBS_JSON_URL"
117114
fi
118115
fi
119116

@@ -139,7 +136,7 @@ if [ $AR_HAS_COMMIT == "0" ]; then
139136
# make changes to the files
140137
echo "Patching files in branch '$AR_NEW_BRANCH_NAME'..."
141138
rm -rf "$AR_COMPS/arduino/package/package_esp32_index.template.json" && cp -f "$AR_OUT/package_esp32_index.template.json" "$AR_COMPS/arduino/package/package_esp32_index.template.json"
142-
139+
143140
cd $AR_COMPS/arduino
144141

145142
# did any of the files change?

0 commit comments

Comments
 (0)