feat: update version to 1.2.29 and enhance Gitea release workflow with improved error handling and debugging

This commit is contained in:
Manuel Weiser 2025-02-19 10:37:41 +01:00
parent 7a4b1a934f
commit ca4671a7dd
9 changed files with 98 additions and 50 deletions

View File

@ -23,67 +23,115 @@ jobs:
env: env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: | run: |
# Determine API URL if not set # Debug: Print all environment variables (excluding the token)
API_URL="${GITEA_API_URL:-${GITEA_SERVER_URL}/api/v1}" env | grep -v "GITEA_TOKEN"
# Remove trailing slash from server URL if present
SERVER_URL="${GITEA_SERVER_URL%/}"
REPO="${GITEA_REPOSITORY}" REPO="${GITEA_REPOSITORY}"
TAG="${GITEA_REF_NAME}" TAG="${GITEA_REF_NAME}"
VERSION="${TAG#v}" # Remove v prefix if present
if [ -z "$API_URL" ] || [ -z "$REPO" ] || [ -z "$TAG" ]; then echo "Debug environment:"
echo "Error: Required Gitea environment variables are not set" echo "Server URL: $SERVER_URL"
env
exit 1
fi
# Escape changelog content for JSON
CHANGELOG_ESCAPED=$(echo '${{ needs.build.outputs.changelog }}' | jq -sR .)
echo "Creating release for tag: $TAG"
echo "Using API URL: $API_URL"
echo "Repository: $REPO" echo "Repository: $REPO"
echo "Tag: $TAG"
echo "Version: $VERSION"
# Create release using Gitea API # Test API connectivity
RELEASE_DATA=$(cat <<EOF echo "Testing API connectivity..."
{ TEST_RESPONSE=$(curl -v -k -H "Authorization: token ${GITEA_TOKEN}" "${SERVER_URL}/api/v1/version" 2>&1)
"tag_name": "$TAG", echo "API Test Response:"
"name": "Release ${{ needs.build.outputs.version }}", echo "$TEST_RESPONSE"
"body": ${CHANGELOG_ESCAPED}
}
EOF
)
echo "Release data:" # Construct clean API URL
echo "$RELEASE_DATA" | jq '.' API_URL="${SERVER_URL}/api/v1"
RELEASE_URL="${API_URL}/repos/${REPO}/releases"
# Create the release echo "Using Release API URL: $RELEASE_URL"
RELEASE_ID=$(curl -X POST \
# Common curl options
CURL_OPTS="-v -k" # -v for verbose, -k to ignore SSL verification
# Create release with minimal data first
echo "Creating release..."
RELEASE_RESPONSE=$(curl $CURL_OPTS -X POST \
-H "accept: application/json" \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "$RELEASE_DATA" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}" \
"${API_URL}/repos/${REPO}/releases" \ "${RELEASE_URL}" 2>&1)
| tee /dev/stderr \
| jq -r '.id') echo "Full release creation response (including headers):"
echo "$RELEASE_RESPONSE"
# Extract the JSON response (last line)
RELEASE_JSON=$(echo "$RELEASE_RESPONSE" | tail -n 1)
echo "Release JSON response:"
echo "$RELEASE_JSON" | jq '.' || echo "Failed to parse JSON response"
# Get release ID
RELEASE_ID=$(echo "$RELEASE_JSON" | jq -r '.id')
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
echo "Failed to create release" echo "Failed to create release. Full response:"
echo "$RELEASE_RESPONSE"
# Try to get more detailed error information
ERROR_MSG=$(echo "$RELEASE_JSON" | jq -r '.message // .error // "Unknown error"')
echo "Error message: $ERROR_MSG"
exit 1 exit 1
fi fi
echo "Created release with ID: $RELEASE_ID" echo "Successfully created release with ID: $RELEASE_ID"
# Upload the binary files # Upload assets
for file in "filaman_full.bin" "filaman_ota.bin"; do for file in "filaman_full.bin" "filaman_ota.bin"; do
echo "Uploading $file..." echo "Uploading $file..."
RESPONSE=$(curl -X POST \ UPLOAD_URL="${RELEASE_URL}/${RELEASE_ID}/assets?name=${file}"
echo "Upload URL: $UPLOAD_URL"
UPLOAD_RESPONSE=$(curl $CURL_OPTS -X POST \
-H "accept: application/json" \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary @"firmware/$file" \ --data-binary "@firmware/${file}" \
"${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=$file") "${UPLOAD_URL}" 2>&1)
if echo "$RESPONSE" | jq -e '.id' > /dev/null; then echo "Full upload response for $file (including headers):"
echo "Successfully uploaded $file" echo "$UPLOAD_RESPONSE"
else
echo "Failed to upload $file" # Extract the JSON response (last line)
echo "Response: $RESPONSE" UPLOAD_JSON=$(echo "$UPLOAD_RESPONSE" | tail -n 1)
echo "Upload JSON response:"
echo "$UPLOAD_JSON" | jq '.' || echo "Failed to parse JSON response"
if ! echo "$UPLOAD_JSON" | jq -e '.id' > /dev/null; then
echo "Failed to upload $file. Full response:"
echo "$UPLOAD_RESPONSE"
ERROR_MSG=$(echo "$UPLOAD_JSON" | jq -r '.message // .error // "Unknown error"')
echo "Error message: $ERROR_MSG"
exit 1 exit 1
fi fi
done
echo "Successfully uploaded $file"
done
# Update release with full description after successful file upload
echo "Updating release description..."
CHANGELOG='${{ needs.build.outputs.changelog }}'
UPDATE_RESPONSE=$(curl $CURL_OPTS -X PATCH \
-H "accept: application/json" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"body\":$(echo "$CHANGELOG" | jq -R -s .)}" \
"${RELEASE_URL}/${RELEASE_ID}" 2>&1)
echo "Full update response (including headers):"
echo "$UPDATE_RESPONSE"
# Extract the JSON response (last line)
UPDATE_JSON=$(echo "$UPDATE_RESPONSE" | tail -n 1)
echo "Update JSON response:"
echo "$UPDATE_JSON" | jq '.' || echo "Failed to parse JSON response"
echo "Release process completed"

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
<div style="display: flex; align-items: center; gap: 2rem;"> <div style="display: flex; align-items: center; gap: 2rem;">
<img src="/logo.png" alt="FilaMan Logo" class="logo"> <img src="/logo.png" alt="FilaMan Logo" class="logo">
<div class="logo-text"> <div class="logo-text">
<h1>FilaMan<span class="version">v1.2.4</span></h1> <h1>FilaMan<span class="version">v1.2.29</span></h1>
<h4>Filament Management Tool</h4> <h4>Filament Management Tool</h4>
</div> </div>
</div> </div>

View File

@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[common] [common]
version = "1.2.28" version = "1.2.29"
[env:esp32dev] [env:esp32dev]
platform = espressif32 platform = espressif32