diff --git a/.gitea/workflows/update-server.yml b/.gitea/workflows/update-server.yml
index 73f4e2a3..e6a19247 100644
--- a/.gitea/workflows/update-server.yml
+++ b/.gitea/workflows/update-server.yml
@@ -270,37 +270,34 @@ jobs:
SHA256=""
fi
- # -- Build the new entry -----------------------------------------
+ # -- Build the new entry (canonical format matching release.yml) --
NEW_ENTRY=""
NEW_ENTRY="${NEW_ENTRY} \n"
NEW_ENTRY="${NEW_ENTRY} ${EXT_NAME}\n"
- NEW_ENTRY="${NEW_ENTRY} ${EXT_NAME} (${STABILITY})\n"
+ NEW_ENTRY="${NEW_ENTRY} ${EXT_NAME} ${STABILITY} build.\n"
NEW_ENTRY="${NEW_ENTRY} ${EXT_ELEMENT}\n"
NEW_ENTRY="${NEW_ENTRY} ${EXT_TYPE}\n"
- NEW_ENTRY="${NEW_ENTRY} ${DISPLAY_VERSION}\n"
- NEW_ENTRY="${NEW_ENTRY} $(date +%Y-%m-%d)\n"
[ -n "$CLIENT_TAG" ] && NEW_ENTRY="${NEW_ENTRY} ${CLIENT_TAG}\n"
[ -n "$FOLDER_TAG" ] && NEW_ENTRY="${NEW_ENTRY} ${FOLDER_TAG}\n"
- NEW_ENTRY="${NEW_ENTRY} \n"
- NEW_ENTRY="${NEW_ENTRY} ${STABILITY}\n"
- NEW_ENTRY="${NEW_ENTRY} \n"
- NEW_ENTRY="${NEW_ENTRY} ${INFO_URL}\n"
+ NEW_ENTRY="${NEW_ENTRY} ${VERSION}\n"
+ NEW_ENTRY="${NEW_ENTRY} $(date +%Y-%m-%d)\n"
+ NEW_ENTRY="${NEW_ENTRY} https://git.mokoconsulting.tech/${GITEA_ORG}/${GITEA_REPO}/releases/tag/${RELEASE_TAG}\n"
NEW_ENTRY="${NEW_ENTRY} \n"
- NEW_ENTRY="${NEW_ENTRY} ${DOWNLOAD_URL}\n"
+ NEW_ENTRY="${NEW_ENTRY} ${DOWNLOAD_URL}\n"
NEW_ENTRY="${NEW_ENTRY} \n"
[ -n "$SHA256" ] && NEW_ENTRY="${NEW_ENTRY} ${SHA256}\n"
- NEW_ENTRY="${NEW_ENTRY} ${TARGET_PLATFORM}\n"
- [ -n "$PHP_TAG" ] && NEW_ENTRY="${NEW_ENTRY} ${PHP_TAG}\n"
+ NEW_ENTRY="${NEW_ENTRY} ${STABILITY}\n"
NEW_ENTRY="${NEW_ENTRY} Moko Consulting\n"
NEW_ENTRY="${NEW_ENTRY} https://mokoconsulting.tech\n"
+ NEW_ENTRY="${NEW_ENTRY} \n"
+ [ -n "$PHP_MINIMUM" ] && NEW_ENTRY="${NEW_ENTRY} ${PHP_MINIMUM}\n"
NEW_ENTRY="${NEW_ENTRY} "
# -- Write new entry to temp file --------------------------------
printf '%b' "$NEW_ENTRY" > /tmp/new_entry.xml
- # -- Merge into updates.xml (only update this stability channel) -
- # Cascading update: each stability level updates itself and all lower levels
- # stable → all | rc → rc,beta,alpha,dev | beta → beta,alpha,dev | alpha → alpha,dev | dev → dev
+ # -- Merge into updates.xml ----------------------------------------
+ # Cascade: stable→all | rc→rc+lower | beta→beta+lower | alpha→alpha+dev | dev→dev
CASCADE_MAP="stable:development,alpha,beta,rc,stable rc:development,alpha,beta,rc beta:development,alpha,beta alpha:development,alpha development:development"
TARGETS=""
for entry in $CASCADE_MAP; do
@@ -313,62 +310,54 @@ jobs:
done
[ -z "$TARGETS" ] && TARGETS="${STABILITY}"
+ echo "Cascade: ${STABILITY} → ${TARGETS}"
+
+ # Create updates.xml if missing
if [ ! -f "updates.xml" ]; then
printf '%s\n' "" > updates.xml
- printf '%s\n' "" >> updates.xml
- printf '%s\n' "" >> updates.xml
- printf '%s\n' '' >> updates.xml
- cat /tmp/new_entry.xml >> updates.xml
- printf '\n%s\n' '' >> updates.xml
- else
- # Replace each cascading channel with the new entry (different tag)
- export PY_TARGETS="$TARGETS"
- python3 << PYEOF
+ printf '%s\n' "" >> updates.xml
+ printf '%s\n' "" >> updates.xml
+ printf '%s\n' "" >> updates.xml
+ fi
+
+ # Update existing blocks or create missing ones
+ export PY_TARGETS="$TARGETS" PY_VERSION="$VERSION" PY_DATE="$(date +%Y-%m-%d)"
+ python3 << 'PYEOF'
import re, os
+
targets = os.environ["PY_TARGETS"].split(",")
- stability = "${STABILITY}"
+ version = os.environ["PY_VERSION"]
+ date = os.environ["PY_DATE"]
+
with open("updates.xml") as f:
content = f.read()
with open("/tmp/new_entry.xml") as f:
new_entry_template = f.read()
+
for tag in targets:
tag = tag.strip()
- # Build entry with this tag
+ # Build entry with this tag's name
new_entry = re.sub(r"[^<]*", f"{tag}", new_entry_template)
- # Remove existing entry for this tag
- pattern = r" .*?" + re.escape(tag) + r".*?\n?"
- content = re.sub(pattern, "", content, flags=re.DOTALL)
- # Insert before
- content = content.replace("", new_entry + "\n")
+
+ # Try to find existing block (handles both single-line and multi-line )
+ block_pattern = r"((?:(?!).)*?" + re.escape(tag) + r".*?)"
+ match = re.search(block_pattern, content, re.DOTALL)
+
+ if match:
+ # Update in place — replace entire block
+ content = content.replace(match.group(1), new_entry.strip())
+ print(f" UPDATED: {tag} → {version}")
+ else:
+ # Create — insert before
+ content = content.replace("", "\n" + new_entry.strip() + "\n\n")
+ print(f" CREATED: {tag} → {version}")
+
+ # Clean up excessive blank lines
content = re.sub(r"\n{3,}", "\n\n", content)
+
with open("updates.xml", "w") as f:
f.write(content)
PYEOF
- if [ $? -ne 0 ]; then
- # Fallback: rebuild keeping other stability entries
- {
- printf '%s\n' ""
- printf '%s\n' ""
- printf '%s\n' ""
- printf '%s\n' ''
- for TAG in stable rc development; do
- [ "$TAG" = "${STABILITY}" ] && continue
- if grep -q "${TAG}" updates.xml 2>/dev/null; then
- sed -n "//,/<\/update>/{ /${TAG}<\/tag>/p; }" updates.xml
- fi
- done
- cat /tmp/new_entry.xml
- printf '\n%s\n' ''
- } > /tmp/updates_new.xml
- mv /tmp/updates_new.xml updates.xml
- fi
- fi
# Commit
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"