ci: only delete zombie versions, not the just-uploaded one
Run 107's clear loop on sweet-cursors deleted the just-uploaded moongreet-git versions. Track per-package "just built" version and skip it in the DELETE loop. Add .type=="arch" jq filter as defense-in-depth.
This commit is contained in:
@@ -80,29 +80,46 @@ jobs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect unique package names (includes split packages like
|
# Collect unique package names + the version we just built for
|
||||||
# foo + foo-debug). We delete ALL existing versions of each
|
# each. We delete only ZOMBIE versions (anything in the registry
|
||||||
# before upload: Gitea's Arch registry doesn't fully regenerate
|
# for this name that is NOT the version we just built) to clear
|
||||||
# the repo DB on pkgver change — old entries stick around as
|
# the Gitea Arch DB which doesn't evict on pkgver change.
|
||||||
# zombies and block pacman from seeing updates.
|
#
|
||||||
|
# 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 SEEN_NAMES
|
||||||
|
declare -A KEEP_VERS
|
||||||
for PKG_FILE in "${PKG_FILES[@]}"; do
|
for PKG_FILE in "${PKG_FILES[@]}"; do
|
||||||
base="${PKG_FILE%.pkg.tar.zst}"
|
base="${PKG_FILE%.pkg.tar.zst}"
|
||||||
base="${base%-*}"; base="${base%-*}"; base="${base%-*}"
|
# Strip arch (last -seg), pkgrel (next), pkgver (next) → name.
|
||||||
SEEN_NAMES["$base"]=1
|
# 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
|
done
|
||||||
|
|
||||||
sudo pacman -S --needed --noconfirm jq
|
sudo pacman -S --needed --noconfirm jq
|
||||||
|
|
||||||
for PKG_NAME in "${!SEEN_NAMES[@]}"; do
|
for PKG_NAME in "${!SEEN_NAMES[@]}"; do
|
||||||
echo "==> Clearing existing versions of $PKG_NAME"
|
KEEP="${KEEP_VERS[$PKG_NAME]}"
|
||||||
# Listing API returns every matching package across all types,
|
echo "==> Clearing zombie versions of $PKG_NAME (keep: $KEEP)"
|
||||||
# so we filter by exact name client-side.
|
|
||||||
VERSIONS=$(curl -s \
|
VERSIONS=$(curl -s \
|
||||||
-H "Authorization: token ${{ secrets.PKG_REGISTRY_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.PKG_REGISTRY_TOKEN }}" \
|
||||||
"https://gitea.moonarch.de/api/v1/packages/nevaforget?type=arch&q=${PKG_NAME}&page=1&limit=100" \
|
"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
|
for V in $VERSIONS; do
|
||||||
|
if [ "$V" = "$KEEP" ]; then
|
||||||
|
echo " skip $PKG_NAME@$V (just built)"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
echo " delete $PKG_NAME@$V"
|
echo " delete $PKG_NAME@$V"
|
||||||
DEL_CODE=$(curl -s -o /dev/null -w '%{http_code}' -X DELETE \
|
DEL_CODE=$(curl -s -o /dev/null -w '%{http_code}' -X DELETE \
|
||||||
-H "Authorization: token ${{ secrets.PKG_REGISTRY_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.PKG_REGISTRY_TOKEN }}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user