workflow: enhance Gitea release process with debug outputs and API connection checks
This commit is contained in:
parent
519a089684
commit
e0a2dff5fe
52
.github/workflows/gitea-release.yml
vendored
52
.github/workflows/gitea-release.yml
vendored
@ -81,22 +81,40 @@ jobs:
|
|||||||
VERSION=${{ steps.get_version.outputs.VERSION }}
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
cd .pio/build/esp32dev
|
cd .pio/build/esp32dev
|
||||||
|
|
||||||
|
# Debug-Ausgaben
|
||||||
|
echo "Debug: Checking API URL..."
|
||||||
|
echo "GITEA_API_URL=${GITEA_API_URL}"
|
||||||
|
|
||||||
# Prepare files for upload
|
# Prepare files for upload
|
||||||
FILES=""
|
FILES=""
|
||||||
for file in upgrade_filaman_firmware_v${VERSION}.bin upgrade_filaman_website_v${VERSION}.bin filaman_full_${VERSION}.bin; do
|
for file in upgrade_filaman_firmware_v${VERSION}.bin upgrade_filaman_website_v${VERSION}.bin filaman_full_${VERSION}.bin; do
|
||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
FILES="$FILES -a $file"
|
FILES="$FILES -a $file"
|
||||||
|
echo "Debug: Found file: $file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if tag exists
|
# Check if tag exists
|
||||||
if ! git rev-parse "v${VERSION}" >/dev/null 2>&1; then
|
if ! git rev-parse "v${VERSION}" >/dev/null 2>&1; then
|
||||||
# Create tag if it doesn't exist
|
echo "Debug: Creating new tag v${VERSION}"
|
||||||
git tag -a "v${VERSION}" -m "Release ${VERSION}"
|
git tag -a "v${VERSION}" -m "Release ${VERSION}"
|
||||||
git push origin "v${VERSION}"
|
git push origin "v${VERSION}"
|
||||||
|
else
|
||||||
|
echo "Debug: Tag v${VERSION} already exists"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Test API connection
|
||||||
|
echo "Debug: Testing API connection..."
|
||||||
|
TEST_RESPONSE=$(curl -s -w "\n%{http_code}" -H "Authorization: token ${GITEA_TOKEN}" "${GITEA_API_URL}/api/v1/version")
|
||||||
|
TEST_STATUS=$(echo "$TEST_RESPONSE" | tail -n1)
|
||||||
|
if [ "$TEST_STATUS" != "200" ]; then
|
||||||
|
echo "Error: Cannot connect to Gitea API"
|
||||||
|
echo "Response: $TEST_RESPONSE"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create Gitea release using API
|
# Create Gitea release using API
|
||||||
|
echo "Debug: Creating release..."
|
||||||
RELEASE_DATA="{
|
RELEASE_DATA="{
|
||||||
\"tag_name\": \"v${VERSION}\",
|
\"tag_name\": \"v${VERSION}\",
|
||||||
\"name\": \"v${VERSION}\",
|
\"name\": \"v${VERSION}\",
|
||||||
@ -104,37 +122,19 @@ jobs:
|
|||||||
}"
|
}"
|
||||||
|
|
||||||
# Create release and capture HTTP status
|
# Create release and capture HTTP status
|
||||||
RESPONSE=$(curl -s -w "%{http_code}" -X POST \
|
RESPONSE=$(curl -v -s -w "\n%{http_code}" -X POST \
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$RELEASE_DATA" \
|
-d "$RELEASE_DATA" \
|
||||||
"${GITEA_API_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases")
|
"${GITEA_API_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases")
|
||||||
|
|
||||||
HTTP_STATUS=${RESPONSE: -3}
|
HTTP_STATUS=$(echo "$RESPONSE" | tail -n1)
|
||||||
RESPONSE_BODY=${RESPONSE:0:-3}
|
RESPONSE_BODY=$(echo "$RESPONSE" | head -n -1)
|
||||||
|
|
||||||
|
echo "Debug: HTTP Status: $HTTP_STATUS"
|
||||||
|
echo "Debug: Response Body: $RESPONSE_BODY"
|
||||||
|
|
||||||
if [ "$HTTP_STATUS" != "201" ]; then
|
if [ "$HTTP_STATUS" != "201" ]; then
|
||||||
echo "Fehler beim Erstellen des Releases: $RESPONSE_BODY"
|
echo "Fehler beim Erstellen des Releases: $RESPONSE_BODY"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract release ID from response
|
|
||||||
RELEASE_ID=$(echo "$RESPONSE_BODY" | jq -r .id)
|
|
||||||
|
|
||||||
# Upload assets
|
|
||||||
for file in upgrade_filaman_firmware_v${VERSION}.bin upgrade_filaman_website_v${VERSION}.bin filaman_full_${VERSION}.bin; do
|
|
||||||
if [ -f "$file" ]; then
|
|
||||||
echo "Uploading $file..."
|
|
||||||
UPLOAD_RESPONSE=$(curl -s -w "%{http_code}" -X POST \
|
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/octet-stream" \
|
|
||||||
--data-binary @"$file" \
|
|
||||||
"${GITEA_API_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases/${RELEASE_ID}/assets?name=${file}")
|
|
||||||
|
|
||||||
UPLOAD_STATUS=${UPLOAD_RESPONSE: -3}
|
|
||||||
if [ "$UPLOAD_STATUS" != "201" ]; then
|
|
||||||
echo "Fehler beim Upload von $file"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
Loading…
x
Reference in New Issue
Block a user