Private
Public Access
1
0

ci: Fix release step with hardcoded repo path and error handling
Some checks failed
Build .deb Package / build-and-package (push) Failing after 2m12s

- GITHUB_REPOSITORY may be empty in linux:host mode
- Added REPO fallback to echo/linux_patch_manager
- Added REF_NAME fallback for GITHUB_REF_NAME
- Added HTTP status code check before parsing release JSON
- Debug output for API response
This commit is contained in:
2026-04-24 12:02:50 +00:00
parent e6829d0aa9
commit 101eb81f16

View File

@ -150,17 +150,28 @@ jobs:
DEB_NAME=$(ls linux-patch-manager_*.deb) DEB_NAME=$(ls linux-patch-manager_*.deb)
VERSION="${{ steps.version.outputs.version }}" VERSION="${{ steps.version.outputs.version }}"
TOKEN="${GITHUB_TOKEN:-$GITEA_TOKEN}" TOKEN="${GITHUB_TOKEN:-$GITEA_TOKEN}"
REF_NAME="${GITHUB_REF_NAME:-v${VERSION}}"
REPO="${GITHUB_REPOSITORY:-echo/linux_patch_manager}"
echo "Creating release for tag: ${REF_NAME} repo: ${REPO}"
echo "DEB: ${DEB_NAME}"
# Create release via Gitea API # Create release via Gitea API
curl -s -X POST \ HTTP_CODE=$(curl -s -o release.json -w "%{http_code}" -X POST \
"http://192.168.2.189:3000/api/v1/repos/${GITHUB_REPOSITORY}/releases" \ "http://192.168.2.189:3000/api/v1/repos/${REPO}/releases" \
-H "Authorization: token ${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\": \"${GITHUB_REF_NAME}\", \"title\": \"Release ${VERSION}\", \"body\": \"Automated build from tag ${GITHUB_REF_NAME}.\\n\\n## Installation\\n\\n\\\`\\\`\\\`bash\\nsudo apt install ./linux-patch-manager_${VERSION}-1_amd64.deb\\n\\\`\\\`\\\`\\\"}" \ -d "{\"tag_name\": \"${REF_NAME}\", \"title\": \"Release ${VERSION}\", \"body\": \"Automated build from tag ${REF_NAME}.\\n\\n## Installation\\n\\n\\\`\\\`\\\`bash\\nsudo apt install ./linux-patch-manager_${VERSION}-1_amd64.deb\\n\\\`\\\`\\\`\\\"}")
-o release.json echo "Release API HTTP status: ${HTTP_CODE}"
cat release.json
if [ "${HTTP_CODE}" != "201" ]; then
echo "ERROR: Failed to create release (HTTP ${HTTP_CODE})"
exit 1
fi
# Extract release ID and upload .deb # Extract release ID and upload .deb
RELEASE_ID=$(python3 -c "import json; print(json.load(open('release.json'))['id'])") RELEASE_ID=$(python3 -c "import json; print(json.load(open('release.json'))['id'])")
echo "Release ID: ${RELEASE_ID}"
curl -s -X POST \ curl -s -X POST \
"http://192.168.2.189:3000/api/v1/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" \ "http://192.168.2.189:3000/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${TOKEN}" \ -H "Authorization: token ${TOKEN}" \
-F "attachment=@${DEB_NAME}" \ -F "attachment=@${DEB_NAME}" \
-F "name=${DEB_NAME}" -F "name=${DEB_NAME}"
echo "Release upload complete"