ci: update GitHub release workflow to improve file upload handling
This commit is contained in:
parent
ab083f5f57
commit
59cc00ca13
58
.github/workflows/github-release.yml
vendored
58
.github/workflows/github-release.yml
vendored
@ -17,6 +17,8 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
@ -104,40 +106,34 @@ jobs:
|
|||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
cd .pio/build/esp32dev
|
cd .pio/build/esp32dev
|
||||||
|
|
||||||
# Create the release first
|
# Create release with available files
|
||||||
RELEASE_JSON=$(curl -L \
|
FILES_TO_UPLOAD=""
|
||||||
-X POST \
|
|
||||||
-H "Accept: application/vnd.github+json" \
|
|
||||||
-H "Authorization: Bearer $GITHUB_TOKEN" \
|
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
"https://api.github.com/repos/$GITHUB_REPOSITORY/releases" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\":\"v${VERSION}\",
|
|
||||||
\"name\":\"Release ${VERSION}\",
|
|
||||||
\"body\":\"${{ steps.changelog.outputs.CHANGES }}\",
|
|
||||||
\"draft\":false,
|
|
||||||
\"prerelease\":false
|
|
||||||
}")
|
|
||||||
|
|
||||||
# Extract the upload URL from the response
|
# Always add firmware
|
||||||
UPLOAD_URL=$(echo "$RELEASE_JSON" | jq -r .upload_url | sed 's/{?name,label}//')
|
if [ -f "filaman_${VERSION}.bin" ]; then
|
||||||
|
FILES_TO_UPLOAD="$FILES_TO_UPLOAD filaman_${VERSION}.bin"
|
||||||
|
fi
|
||||||
|
|
||||||
# Upload the binary files
|
# Add SPIFFS and full binary only if they exist
|
||||||
for file in filaman_${VERSION}.bin webpage_${VERSION}.bin filaman_full_${VERSION}.bin; do
|
if [ -f "webpage_${VERSION}.bin" ]; then
|
||||||
if [ -f "$file" ]; then
|
FILES_TO_UPLOAD="$FILES_TO_UPLOAD webpage_${VERSION}.bin"
|
||||||
echo "Uploading $file..."
|
fi
|
||||||
curl -L \
|
|
||||||
-X POST \
|
if [ -f "filaman_full_${VERSION}.bin" ]; then
|
||||||
-H "Accept: application/vnd.github+json" \
|
FILES_TO_UPLOAD="$FILES_TO_UPLOAD filaman_full_${VERSION}.bin"
|
||||||
-H "Authorization: Bearer $GITHUB_TOKEN" \
|
fi
|
||||||
-H "X-GitHub-Api-Version: 2022-11-28" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
# Create release with available files
|
||||||
"${UPLOAD_URL}?name=${file}" \
|
if [ -n "$FILES_TO_UPLOAD" ]; then
|
||||||
--data-binary "@${file}"
|
gh release create "v${VERSION}" \
|
||||||
fi
|
--title "Release ${VERSION}" \
|
||||||
done
|
--notes "${{ steps.changelog.outputs.CHANGES }}" \
|
||||||
|
$FILES_TO_UPLOAD
|
||||||
|
else
|
||||||
|
echo "Error: No files found to upload"
|
||||||
|
exit 1
|
Loading…
x
Reference in New Issue
Block a user