@@ -181,14 +181,14 @@ jobs:
181181 - name : Create Github Release
182182 if : steps.build.outputs.artifactsFound == 'true'
183183 run : |
184+ set +e # Disable exit-on-error to allow custom error handling
184185 printf -v red '\033[0;31m'
185186 printf -v yellow '\033[0;33m'
186187 printf -v green '\033[0;32m'
187188 printf -v bold '\033[1m'
188189 printf -v reset '\033[0m'
189190
190191 echo "::group::Creating GitHub Release"
191- # Prepare the changelog body, preserving Markdown formatting
192192 changelog_file="releases/${RELEASE_NAME}/Release-Changelog.md"
193193 if [ -f "$changelog_file" ] && [ -s "$changelog_file" ]; then
194194 body=$(jq -R -s '.' < "$changelog_file")
@@ -197,7 +197,6 @@ jobs:
197197 body=$(jq -R -s '.' <<< "Release ${RELEASE_NAME}")
198198 fi
199199
200- # Construct JSON payload
201200 json_payload=$(jq -n \
202201 --arg tag "$RELEASE_NAME" \
203202 --arg name "$RELEASE_NAME" \
@@ -240,9 +239,8 @@ jobs:
240239 failure_count=0
241240 max_retries=2
242241
243- # Debug: List files to upload
244242 echo "Files to upload:"
245- ls -l releases/${RELEASE_NAME}/
243+ ls -l releases/${RELEASE_NAME}/ || echo "No files found in releases/${RELEASE_NAME}/"
246244
247245 for file in releases/${RELEASE_NAME}/*; do
248246 if [ -f "$file" ]; then
@@ -252,23 +250,32 @@ jobs:
252250 success=false
253251
254252 while [ $attempt -lt $max_retries ] && [ "$success" = false ]; do
255- # Run curl with explicit error handling
253+ # Explicitly capture curl output and status, even on failure
254+ set +e # Ensure curl failure doesn't exit the script
256255 upload_response=$(curl -s -w "\n%{http_code}" \
257256 -H "Authorization: token ${NODE_AUTH_TOKEN}" \
258257 -H "Content-Type: application/octet-stream" \
259258 --data-binary @"$file" \
260- "$UPLOAD_URL?name=$filename" || echo "curl failed with exit code $?"; echo "999")
259+ "$UPLOAD_URL?name=$filename")
260+ curl_exit_code=$?
261+ set -e # Re-enable if needed after curl
262+
261263 upload_status=$(echo "$upload_response" | tail -n1)
262264 upload_body=$(echo "$upload_response" | sed '$d')
263265
264- if [ "$upload_status" -eq 201 ]; then
266+ if [ $curl_exit_code -ne 0 ]; then
267+ echo "${red}curl command failed with exit code $curl_exit_code${reset}"
268+ echo "Upload Response: $upload_response"
269+ ((attempt++))
270+ [ $attempt -lt $max_retries ] && sleep 2
271+ elif [ "$upload_status" -eq 201 ]; then
265272 echo "${green}Successfully uploaded $filename (HTTP $upload_status)${reset}"
266273 success=true
267274 ((success_count++))
268275 else
269- ((attempt++))
270276 echo "${red}Upload attempt $attempt failed for $filename (HTTP $upload_status)${reset}"
271277 echo "Upload Response: $upload_body"
278+ ((attempt++))
272279 [ $attempt -lt $max_retries ] && sleep 2
273280 fi
274281 done
0 commit comments