From 101eb81f1629cd25c679a87002751db157bb523e Mon Sep 17 00:00:00 2001 From: Echo Date: Fri, 24 Apr 2026 12:02:50 +0000 Subject: [PATCH] ci: Fix release step with hardcoded repo path and error handling - 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 --- .gitea/workflows/build.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 6adc0ad..e61230f 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -150,17 +150,28 @@ jobs: DEB_NAME=$(ls linux-patch-manager_*.deb) VERSION="${{ steps.version.outputs.version }}" 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 - curl -s -X POST \ - "http://192.168.2.189:3000/api/v1/repos/${GITHUB_REPOSITORY}/releases" \ + HTTP_CODE=$(curl -s -o release.json -w "%{http_code}" -X POST \ + "http://192.168.2.189:3000/api/v1/repos/${REPO}/releases" \ -H "Authorization: token ${TOKEN}" \ -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\\\`\\\`\\\`\\\"}" \ - -o release.json + -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\\\`\\\`\\\`\\\"}") + 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 RELEASE_ID=$(python3 -c "import json; print(json.load(open('release.json'))['id'])") + echo "Release ID: ${RELEASE_ID}" 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}" \ -F "attachment=@${DEB_NAME}" \ -F "name=${DEB_NAME}" + echo "Release upload complete"