fix(ci): remove all duplicate assets before re-uploading in publish-gitea-release.sh
Build & Publish Release / Build Packages & Publish to Gitea (push) Failing after 1m19s
Build & Publish Release / Build Packages & Publish to Gitea (push) Failing after 1m19s
This commit is contained in:
@@ -177,33 +177,34 @@ upload_asset() {
|
|||||||
local encoded_name
|
local encoded_name
|
||||||
encoded_name=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "${filename}")
|
encoded_name=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))' "${filename}")
|
||||||
|
|
||||||
# Prüfen, ob bereits ein Asset mit demselben Namen existiert
|
# Prüfen, ob bereits Assets mit demselben Namen existieren (können mehrere sein)
|
||||||
local existing_id=""
|
local existing_ids=()
|
||||||
if [ -f "${ASSETS_LIST_FILE}" ] && [ -s "${ASSETS_LIST_FILE}" ]; then
|
if [ -f "${ASSETS_LIST_FILE}" ] && [ -s "${ASSETS_LIST_FILE}" ]; then
|
||||||
existing_id=$(python3 -c '
|
mapfile -t existing_ids < <(python3 -c '
|
||||||
import sys, json
|
import sys, json
|
||||||
try:
|
try:
|
||||||
assets = json.load(open(sys.argv[1]))
|
assets = json.load(open(sys.argv[1]))
|
||||||
target = sys.argv[2]
|
target = sys.argv[2]
|
||||||
for a in assets:
|
for a in assets:
|
||||||
if a.get("name") == target:
|
if a.get("name") == target and a.get("id"):
|
||||||
print(a.get("id", ""))
|
print(a.get("id"))
|
||||||
break
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
' "${ASSETS_LIST_FILE}" "${filename}")
|
' "${ASSETS_LIST_FILE}" "${filename}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "${existing_id}" ]; then
|
for eid in "${existing_ids[@]}"; do
|
||||||
echo "Lösche bestehendes Asset '${filename}' (ID: ${existing_id}) vor Re-Upload..."
|
if [ -n "${eid}" ]; then
|
||||||
local del_status
|
echo "Lösche bestehendes Asset '${filename}' (ID: ${eid}) vor Re-Upload..."
|
||||||
del_status=$(curl -s -S -o /dev/null -w "%{http_code}" \
|
local del_status
|
||||||
-X DELETE "${API_BASE}/releases/${RELEASE_ID}/assets/${existing_id}" \
|
del_status=$(curl -s -S -o /dev/null -w "%{http_code}" \
|
||||||
-H "Authorization: token ${TOKEN}" || echo "000")
|
-X DELETE "${API_BASE}/releases/${RELEASE_ID}/assets/${eid}" \
|
||||||
if [ "${del_status}" != "204" ] && [ "${del_status}" != "200" ]; then
|
-H "Authorization: token ${TOKEN}" || echo "000")
|
||||||
echo "Warnung: Löschen von bestehendem Asset '${filename}' ergab HTTP ${del_status}."
|
if [ "${del_status}" != "204" ] && [ "${del_status}" != "200" ]; then
|
||||||
|
echo "Warnung: Löschen von bestehendem Asset '${filename}' ergab HTTP ${del_status}."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
|
|
||||||
echo "Lade Asset hoch: ${filename}..."
|
echo "Lade Asset hoch: ${filename}..."
|
||||||
local upload_res_file="$(mktemp)"
|
local upload_res_file="$(mktemp)"
|
||||||
|
|||||||
Reference in New Issue
Block a user