diff --git a/.gitea/workflows/build-and-publish.yaml b/.gitea/workflows/build-and-publish.yaml index ea27b28..d1ec173 100644 --- a/.gitea/workflows/build-and-publish.yaml +++ b/.gitea/workflows/build-and-publish.yaml @@ -80,29 +80,46 @@ jobs: continue fi - # Collect unique package names (includes split packages like - # foo + foo-debug). We delete ALL existing versions of each - # before upload: Gitea's Arch registry doesn't fully regenerate - # the repo DB on pkgver change — old entries stick around as - # zombies and block pacman from seeing updates. + # Collect unique package names + the version we just built for + # each. We delete only ZOMBIE versions (anything in the registry + # for this name that is NOT the version we just built) to clear + # the Gitea Arch DB which doesn't evict on pkgver change. + # + # Run 107 (2026-04-28) showed the previous "delete all versions" + # logic killed cross-package state when multiple PKGBUILDs were + # built in one run — sweet-cursors's clear loop deleted the + # just-uploaded moongreet-git versions. The skip-current-version + # logic + .type=="arch" filter prevent that recurrence. declare -A SEEN_NAMES + declare -A KEEP_VERS for PKG_FILE in "${PKG_FILES[@]}"; do base="${PKG_FILE%.pkg.tar.zst}" - base="${base%-*}"; base="${base%-*}"; base="${base%-*}" - SEEN_NAMES["$base"]=1 + # Strip arch (last -seg), pkgrel (next), pkgver (next) → name. + # Keep "$pkgver-$pkgrel" as the full version. + arch_stripped="${base%-*}" + rel_stripped="${arch_stripped%-*}" + ver_stripped="${rel_stripped%-*}" + pkg_name="$ver_stripped" + full_ver="${arch_stripped#${ver_stripped}-}" + SEEN_NAMES["$pkg_name"]=1 + KEEP_VERS["$pkg_name"]="$full_ver" done sudo pacman -S --needed --noconfirm jq for PKG_NAME in "${!SEEN_NAMES[@]}"; do - echo "==> Clearing existing versions of $PKG_NAME" - # Listing API returns every matching package across all types, - # so we filter by exact name client-side. + KEEP="${KEEP_VERS[$PKG_NAME]}" + echo "==> Clearing zombie versions of $PKG_NAME (keep: $KEEP)" VERSIONS=$(curl -s \ -H "Authorization: token ${{ secrets.PKG_REGISTRY_TOKEN }}" \ "https://gitea.moonarch.de/api/v1/packages/nevaforget?type=arch&q=${PKG_NAME}&page=1&limit=100" \ - | jq -r --arg n "$PKG_NAME" '.[] | select(.name==$n) | .version') + | jq -r --arg n "$PKG_NAME" --arg t "arch" \ + '.[] | select(.name==$n and .type==$t) | .version') for V in $VERSIONS; do + if [ "$V" = "$KEEP" ]; then + echo " skip $PKG_NAME@$V (just built)" + continue + fi echo " delete $PKG_NAME@$V" DEL_CODE=$(curl -s -o /dev/null -w '%{http_code}' -X DELETE \ -H "Authorization: token ${{ secrets.PKG_REGISTRY_TOKEN }}" \