ci: make apt registry upload idempotent (tolerate 409) #31

Merged
jessey merged 1 commits from fix/apt-409 into main 2026-05-22 13:26:48 +00:00
+8 -2
View File
@@ -113,13 +113,19 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
if [ -z "${PKG_TOKEN:-}" ]; then if [ -z "${PKG_TOKEN:-}" ]; then
echo "PACKAGES_TOKEN not set — skipping apt publish (the .deb is still a release asset)." echo "REGISTRY_TOKEN not set — skipping apt publish (the .deb is still a release asset)."
exit 0 exit 0
fi fi
OWNER="${{ github.repository_owner }}" OWNER="${{ github.repository_owner }}"
URL="${{ github.server_url }}/api/packages/${OWNER}/debian/pool/stable/main/upload" URL="${{ github.server_url }}/api/packages/${OWNER}/debian/pool/stable/main/upload"
for f in dist/*.deb; do for f in dist/*.deb; do
echo "Uploading $(basename "$f") to the apt registry…" echo "Uploading $(basename "$f") to the apt registry…"
curl -sS --fail --user "${OWNER}:${PKG_TOKEN}" --upload-file "$f" "$URL" code=$(curl -sS -o /tmp/apt_upload.txt -w '%{http_code}' \
--user "${OWNER}:${PKG_TOKEN}" --upload-file "$f" "$URL" || true)
case "$code" in
2*) echo " uploaded ($code)";;
409) echo " already published ($code) — skipping (registry versions are immutable)";;
*) echo " upload failed ($code):"; cat /tmp/apt_upload.txt || true; exit 1;;
esac
done done
echo "apt source: deb ${{ github.server_url }}/api/packages/${OWNER}/debian stable main" echo "apt source: deb ${{ github.server_url }}/api/packages/${OWNER}/debian stable main"