Fix CI: use correct API v1 endpoint for package registry deletion
The DELETE endpoint for Forgejo generic packages is /api/v1/packages/ while the upload (PUT) endpoint is /api/packages/. Using the wrong endpoint caused silent failures, leaving stale latest.json in the registry. Also fail the CI step explicitly on upload failure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4030cc90b2
commit
efb922eb0e
1 changed files with 12 additions and 4 deletions
|
|
@ -209,25 +209,33 @@ jobs:
|
|||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PKG_URL="${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/simpl-resultat/latest"
|
||||
# DELETE uses API v1, PUT uses the package upload API
|
||||
DELETE_URL="${GITHUB_SERVER_URL}/api/v1/packages/${GITHUB_REPOSITORY_OWNER}/generic/simpl-resultat/latest"
|
||||
UPLOAD_URL="${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/simpl-resultat/latest"
|
||||
|
||||
# Delete the old package version to avoid 409 conflicts
|
||||
echo "Deleting old package version (if any)..."
|
||||
DEL_CODE=$(curl -s -w "%{http_code}" -X DELETE \
|
||||
"${PKG_URL}" \
|
||||
"${DELETE_URL}" \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-o /tmp/del_response.json)
|
||||
echo "Delete HTTP $DEL_CODE"
|
||||
# 204 = deleted, 404 = didn't exist (both OK)
|
||||
if [ "$DEL_CODE" != "204" ] && [ "$DEL_CODE" != "404" ]; then
|
||||
echo "WARNING: Unexpected delete response:"
|
||||
cat /tmp/del_response.json
|
||||
fi
|
||||
|
||||
echo "Uploading latest.json to package registry..."
|
||||
HTTP_CODE=$(curl -w "%{http_code}" -X PUT \
|
||||
"${PKG_URL}/latest.json" \
|
||||
"${UPLOAD_URL}/latest.json" \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data-binary "@release-assets/latest.json" \
|
||||
-o /tmp/pkg_response.json)
|
||||
echo "Upload HTTP $HTTP_CODE"
|
||||
if [ "$HTTP_CODE" != "201" ]; then
|
||||
echo "Upload response:"
|
||||
echo "ERROR: Failed to publish latest.json:"
|
||||
cat /tmp/pkg_response.json
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue