fix: add file existence checks before uploading binaries in release workflows

This commit is contained in:
Manuel Weiser 2025-02-20 20:40:14 +01:00
parent cefa81030b
commit 54744a06dd
2 changed files with 34 additions and 12 deletions

View File

@ -107,14 +107,20 @@ jobs:
# Upload binaries # Upload binaries
cd .pio/build/esp32dev cd .pio/build/esp32dev
for file in filaman_ota.bin filaman_spiffs.bin filaman_full.bin; do
echo "Uploading $file..." # Check if files exist before uploading
curl -k -s \ for file in filaman_spiffs.bin filaman_full.bin; do
-X POST \ if [ -f "$file" ]; then
-H "Authorization: token ${TOKEN}" \ echo "Uploading $file..."
-H "Content-Type: application/octet-stream" \ curl -k -s \
--data-binary "@$file" \ -X POST \
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file" -H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$file" \
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file"
else
echo "Warning: $file not found"
fi
done done
else else
echo "Failed to create release. Response:" echo "Failed to create release. Response:"

View File

@ -87,7 +87,23 @@ jobs:
env: env:
GH_TOKEN: ${{ github.token }} GH_TOKEN: ${{ github.token }}
run: | run: |
gh release create "${{ github.ref_name }}" \ # Check which files exist and create a list for upload
--title "Release ${{ steps.get_version.outputs.VERSION }}" \ cd .pio/build/esp32dev
--notes "${{ steps.changelog.outputs.CHANGES }}" \ FILES_TO_UPLOAD=""
.pio/build/esp32dev/filaman_full.bin for file in filaman_spiffs.bin filaman_full.bin; do
if [ -f "$file" ]; then
FILES_TO_UPLOAD="$FILES_TO_UPLOAD .pio/build/esp32dev/$file"
else
echo "Warning: $file not found"
fi
done
# Create release with available files
if [ -n "$FILES_TO_UPLOAD" ]; then
gh release create "${{ github.ref_name }}" \
--title "Release ${{ steps.get_version.outputs.VERSION }}" \
--notes "${{ steps.changelog.outputs.CHANGES }}" \
$FILES_TO_UPLOAD
else
echo "Error: No files found to upload"
exit 1