ci: Joomla release builds ZIP + SHA-256 checksum

Add Step 6b that builds a release ZIP from src/ for waas-component
(Joomla) platforms:
- Zips all files in src/ with root-relative paths
- Computes SHA-256 checksum
- Derives element name from <name> tag (not manifest filename)
- Uploads ZIP as release asset in Step 7

Also fix EXT_ELEMENT derivation in Step 5 (update.xml) to use
<name> tag lowercased instead of manifest filename, so the element
is "mokocassiopeia" not "templateDetails".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 17:47:15 -05:00
parent 8b62bf10ff
commit fe7acc54b3

View File

@@ -266,9 +266,10 @@ jobs:
TARGET_PLATFORM=$(grep -oP '<targetplatform[^/]*/>' "$MANIFEST" 2>/dev/null | head -1 || echo "") TARGET_PLATFORM=$(grep -oP '<targetplatform[^/]*/>' "$MANIFEST" 2>/dev/null | head -1 || echo "")
PHP_MINIMUM=$(grep -oP '<php_minimum>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1 || echo "") PHP_MINIMUM=$(grep -oP '<php_minimum>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1 || echo "")
# Derive element from manifest filename if not in XML # Derive element: for templates use <name> lowercased, fallback to manifest filename
if [ -z "$EXT_ELEMENT" ]; then if [ -z "$EXT_ELEMENT" ]; then
EXT_ELEMENT=$(basename "$MANIFEST" .xml) EXT_ELEMENT=$(grep -oP '<name>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1 | tr '[:upper:]' '[:lower:]' | tr -d ' ' || true)
[ -z "$EXT_ELEMENT" ] && EXT_ELEMENT=$(basename "$MANIFEST" .xml)
fi fi
# Build client tag: plugins and frontend modules need <client>site</client> # Build client tag: plugins and frontend modules need <client>site</client>
@@ -359,6 +360,66 @@ jobs:
git push origin "$TAG" git push origin "$TAG"
echo "🏷️ Tag: ${TAG}" >> $GITHUB_STEP_SUMMARY echo "🏷️ Tag: ${TAG}" >> $GITHUB_STEP_SUMMARY
# ── STEP 6b: Build release ZIP + SHA-256 (Joomla) ──────────────────
- name: "Step 6b: Build Joomla release ZIP"
if: >-
steps.version.outputs.skip != 'true' &&
steps.check.outputs.already_released != 'true'
id: zip
run: |
PLATFORM=$(php /tmp/mokostandards/api/cli/platform_detect.php --path . 2>/dev/null || true)
VERSION="${{ steps.version.outputs.version }}"
if [ "$PLATFORM" != "waas-component" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Resolve source directory
if [ -d "src" ]; then
SRC="src"
elif [ -d "htdocs" ]; then
SRC="htdocs"
else
echo "⚠️ No src/ or htdocs/ directory — skipping ZIP" >> "$GITHUB_STEP_SUMMARY"
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
# Derive element name from template/extension name (lowercase, no spaces)
MANIFEST=$(find . -maxdepth 2 -name "*.xml" -exec grep -l '<extension' {} \; 2>/dev/null | head -1 || true)
EXT_ELEMENT=""
if [ -n "$MANIFEST" ]; then
EXT_ELEMENT=$(grep -oP '<element>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1 || true)
if [ -z "$EXT_ELEMENT" ]; then
# For templates: use <name> tag lowercased
EXT_ELEMENT=$(grep -oP '<name>\K[^<]+' "$MANIFEST" 2>/dev/null | head -1 | tr '[:upper:]' '[:lower:]' | tr -d ' ' || true)
fi
fi
[ -z "$EXT_ELEMENT" ] && EXT_ELEMENT=$(basename "$(pwd)" | tr '[:upper:]' '[:lower:]')
ZIP_NAME="${EXT_ELEMENT}-${VERSION}.zip"
ZIP_PATH="/tmp/${ZIP_NAME}"
# Build ZIP from src/ contents (cd into src so paths are root-relative)
(cd "$SRC" && zip -r "$ZIP_PATH" .)
SHA256=$(sha256sum "$ZIP_PATH" | awk '{print $1}')
echo "zip_path=${ZIP_PATH}" >> "$GITHUB_OUTPUT"
echo "zip_name=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
echo "sha256=${SHA256}" >> "$GITHUB_OUTPUT"
echo "ext_element=${EXT_ELEMENT}" >> "$GITHUB_OUTPUT"
echo "skip=false" >> "$GITHUB_OUTPUT"
{
echo "### 📦 Release ZIP"
echo "| Field | Value |"
echo "|-------|-------|"
echo "| File | \`${ZIP_NAME}\` |"
echo "| SHA-256 | \`${SHA256}\` |"
echo "| Source | \`${SRC}/\` |"
} >> "$GITHUB_STEP_SUMMARY"
# ── STEP 7: Create or update GitHub Release ────────────────────────── # ── STEP 7: Create or update GitHub Release ──────────────────────────
- name: "Step 7: GitHub Release" - name: "Step 7: GitHub Release"
if: >- if: >-
@@ -371,6 +432,8 @@ jobs:
TAG="${{ steps.version.outputs.tag }}" TAG="${{ steps.version.outputs.tag }}"
BRANCH="${{ steps.version.outputs.branch }}" BRANCH="${{ steps.version.outputs.branch }}"
IS_MINOR="${{ steps.version.outputs.is_minor }}" IS_MINOR="${{ steps.version.outputs.is_minor }}"
ZIP_PATH="${{ steps.zip.outputs.zip_path }}"
ZIP_SKIP="${{ steps.zip.outputs.skip }}"
# Derive the minor version base (XX.YY.00) # Derive the minor version base (XX.YY.00)
MINOR_BASE=$(echo "$VERSION" | sed 's/\.[0-9]*$/.00/') MINOR_BASE=$(echo "$VERSION" | sed 's/\.[0-9]*$/.00/')
@@ -380,16 +443,22 @@ jobs:
[ -z "$NOTES" ] && NOTES="Release ${VERSION}" [ -z "$NOTES" ] && NOTES="Release ${VERSION}"
echo "$NOTES" > /tmp/release_notes.md echo "$NOTES" > /tmp/release_notes.md
# Build release command args — include ZIP if built
UPLOAD_ARGS=""
if [ "$ZIP_SKIP" != "true" ] && [ -f "$ZIP_PATH" ]; then
UPLOAD_ARGS="$ZIP_PATH"
fi
if [ "$IS_MINOR" = "true" ]; then if [ "$IS_MINOR" = "true" ]; then
# Minor release: create new GitHub Release # Minor release: create new GitHub Release
gh release create "$TAG" \ gh release create "$TAG" \
--title "${VERSION}" \ --title "${VERSION}" \
--notes-file /tmp/release_notes.md \ --notes-file /tmp/release_notes.md \
--target "$BRANCH" --target "$BRANCH" \
$UPLOAD_ARGS
echo "🚀 Release created: ${VERSION}" >> $GITHUB_STEP_SUMMARY echo "🚀 Release created: ${VERSION}" >> $GITHUB_STEP_SUMMARY
else else
# Patch release: update the existing minor release with new tag # Patch release: update the existing minor release with new tag
# Find the latest release for this minor version
EXISTING=$(gh release view "$MINOR_TAG" --json tagName -q .tagName 2>/dev/null || true) EXISTING=$(gh release view "$MINOR_TAG" --json tagName -q .tagName 2>/dev/null || true)
if [ -n "$EXISTING" ]; then if [ -n "$EXISTING" ]; then
# Update existing release body with patch info # Update existing release body with patch info
@@ -406,12 +475,19 @@ jobs:
gh release edit "$MINOR_TAG" \ gh release edit "$MINOR_TAG" \
--title "${MINOR_BASE} (latest: ${VERSION})" \ --title "${MINOR_BASE} (latest: ${VERSION})" \
--notes-file /tmp/updated_notes.md --notes-file /tmp/updated_notes.md
# Upload ZIP to existing release
if [ "$ZIP_SKIP" != "true" ] && [ -f "$ZIP_PATH" ]; then
gh release upload "$MINOR_TAG" "$ZIP_PATH" --clobber
fi
echo "📝 Release updated: ${MINOR_BASE} → patch ${VERSION}" >> $GITHUB_STEP_SUMMARY echo "📝 Release updated: ${MINOR_BASE} → patch ${VERSION}" >> $GITHUB_STEP_SUMMARY
else else
# No existing minor release found — create one for this patch # No existing minor release found — create one for this patch
gh release create "$TAG" \ gh release create "$TAG" \
--title "${VERSION}" \ --title "${VERSION}" \
--notes-file /tmp/release_notes.md --notes-file /tmp/release_notes.md \
$UPLOAD_ARGS
echo "🚀 Release created: ${VERSION} (no minor release found)" >> $GITHUB_STEP_SUMMARY echo "🚀 Release created: ${VERSION} (no minor release found)" >> $GITHUB_STEP_SUMMARY
fi fi
fi fi