fix(workflows): clean updates.xml on stable release #210
@@ -411,13 +411,13 @@ jobs:
|
||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||
|
||||
# Fetch latest updates.xml from main so preserve logic has all channels
|
||||
# Fetch latest updates.xml from main so preserve logic has current channels
|
||||
GITEA_TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
||||
curl -sf -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
"${API}/contents/updates.xml?ref=main" 2>/dev/null | \
|
||||
php -r "\$d=json_decode(file_get_contents('php://stdin'),true); echo base64_decode(\$d['content'] ?? '');" \
|
||||
> updates.xml 2>/dev/null || true
|
||||
> updates.xml 2>/dev/null || rm -f updates.xml
|
||||
|
||||
SHA_FLAG=""
|
||||
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
||||
|
||||
@@ -491,9 +491,19 @@ if (file_exists($dest)) {
|
||||
if (isset($existingUpdate->tags->tag)) {
|
||||
$existingTag = (string) $existingUpdate->tags->tag;
|
||||
}
|
||||
// Keep entries for channels we're NOT overwriting
|
||||
$existingVersion = (string) ($existingUpdate->version ?? '');
|
||||
// Strip suffixes for comparison
|
||||
$existingBase = preg_replace('/(-(dev|alpha|beta|rc))+$/', '', $existingVersion);
|
||||
$currentBase = preg_replace('/(-(dev|alpha|beta|rc))+$/', '', $version);
|
||||
|
||||
// Keep entries for channels we're NOT overwriting,
|
||||
// but ONLY if their version is >= current (never preserve stale entries)
|
||||
if (!empty($existingTag) && !in_array($existingTag, $writtenChannels, true)) {
|
||||
$preservedEntries[] = ' ' . trim($existingUpdate->asXML());
|
||||
if (version_compare($existingBase, $currentBase, '>=')) {
|
||||
$preservedEntries[] = ' ' . trim($existingUpdate->asXML());
|
||||
} else {
|
||||
echo "Discarding stale {$existingTag} entry (v{$existingVersion} < v{$version})\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user