ci(release): replace existing release assets on republish
VoidBuildSystem CI / 3A · Linux test (relwithdebinfo) (push) Successful in 6m7s
VoidBuildSystem CI / 1 · Requirements (push) Successful in 6s
VoidBuildSystem CI / 2A · Linux build (debug) (push) Successful in 2m29s
VoidBuildSystem CI / 2A · Linux build (sanitizers) (push) Successful in 4m28s
VoidBuildSystem CI / 2A · Linux build (relwithdebinfo) (push) Successful in 5m32s
VoidBuildSystem CI / 3A · Linux test (sanitizers) (push) Successful in 1m8s
VoidBuildSystem CI / 2B · Windows Wine build (debug) (push) Successful in 2m22s
VoidBuildSystem CI / 2B · Windows Wine build (relwithdebinfo) (push) Successful in 3m57s
VoidBuildSystem CI / 3B · Windows Wine test (debug) (push) Successful in 17s
VoidBuildSystem CI / 3B · Windows Wine test (relwithdebinfo) (push) Successful in 17s
VoidBuildSystem CI / 3A · Linux test (debug) (push) Successful in 6m17s
VoidBuildSystem CI / 4A2 · VBS installers (windows target) (push) Waiting to run
VoidBuildSystem CI / 4A2 · VBS installers (linux target) (push) In progress

Re-running the pipeline for an already published tag would otherwise
fail with a 409 on every asset name. Delete the matching asset first.
This commit is contained in:
faumaray committed 2026-12-06 16:32:23 +03:00
1 parent ff562acc1a
commit a3afca0e5f
1 file changed
+9
+9
View File
@@ -508,8 +508,17 @@ jobs:
echo "lookup: ${existing:-<none>}" >&2
exit 1
fi
# Re-running a release replaces its assets: delete the old ones by name first.
existing_assets="$(curl -sS -H "Authorization: token ${TOKEN}" \
"${api}/releases/${release_id}/assets" || true)"
for file in dist/*; do
name="$(basename "${file}")"
asset_id="$(printf '%s' "${existing_assets}" | python3 -c 'import json,sys; name=sys.argv[1]; print(next((a.get("id","") for a in json.load(sys.stdin) if a.get("name")==name), ""))' "${name}" 2>/dev/null || true)"
if [ -n "${asset_id}" ]; then
curl -fsS -X DELETE -H "Authorization: token ${TOKEN}" \
"${api}/releases/assets/${asset_id}" >/dev/null
echo "replaced ${name}"
fi
curl -fsS -X POST -H "Authorization: token ${TOKEN}" \
-F "attachment=@${file}" "${api}/releases/${release_id}/assets?name=${name}" >/dev/null
echo "uploaded ${name}"