Template
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8384940394 | |||
| 789d070dc6 | |||
| 729f21bd3a | |||
| 929cf4d3a8 | |||
| 5600eacfe2 | |||
| 71268c49d3 | |||
| bf94eea7cc | |||
| 358b057019 | |||
| 119287002f | |||
| 7428814950 | |||
| 38420aa8ac | |||
| 777996b545 |
@@ -0,0 +1,84 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow
|
||||||
|
# INGROUP: moko-platform.Release
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
|
# PATH: /.mokogitea/workflows/auto-bump.yml
|
||||||
|
# VERSION: 09.02.00
|
||||||
|
# BRIEF: Auto patch-bump version on every push to dev (skips merge commits)
|
||||||
|
|
||||||
|
name: "Universal: Auto Version Bump"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
bump:
|
||||||
|
name: Version Bump
|
||||||
|
runs-on: release
|
||||||
|
if: >-
|
||||||
|
!contains(github.event.head_commit.message, '[skip ci]') &&
|
||||||
|
!contains(github.event.head_commit.message, '[skip bump]') &&
|
||||||
|
!startsWith(github.event.head_commit.message, 'Merge pull request')
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GA_TOKEN }}
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Setup moko-platform tools
|
||||||
|
run: |
|
||||||
|
if ! command -v composer &> /dev/null; then
|
||||||
|
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
if [ -d "/opt/moko-platform/cli" ]; then
|
||||||
|
echo "MOKO_CLI=/opt/moko-platform/cli" >> "$GITHUB_ENV"
|
||||||
|
else
|
||||||
|
git clone --depth 1 --branch main --quiet \
|
||||||
|
"https://x-access-token:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/MokoConsulting/moko-platform.git" \
|
||||||
|
/tmp/moko-platform-api
|
||||||
|
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet
|
||||||
|
echo "MOKO_CLI=/tmp/moko-platform-api/cli" >> "$GITHUB_ENV"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Bump version
|
||||||
|
run: |
|
||||||
|
BUMP=$(php ${MOKO_CLI}/version_bump.php --path . 2>&1) || true
|
||||||
|
echo "$BUMP"
|
||||||
|
|
||||||
|
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null) || true
|
||||||
|
[ -z "$VERSION" ] && { echo "No version found — skipping"; exit 0; }
|
||||||
|
|
||||||
|
# Propagate to platform manifests
|
||||||
|
php ${MOKO_CLI}/version_set_platform.php \
|
||||||
|
--path . --version "$VERSION" --branch dev 2>/dev/null || true
|
||||||
|
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||||
|
|
||||||
|
# Commit if anything changed
|
||||||
|
if git diff --quiet && git diff --cached --quiet; then
|
||||||
|
echo "No version changes to commit"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
git remote set-url origin "https://jmiller:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
|
git add -A
|
||||||
|
git commit -m "chore(version): patch bump to ${VERSION} [skip ci]" \
|
||||||
|
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
||||||
|
git push origin dev
|
||||||
|
echo "Bumped to ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,225 +1,223 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
#
|
#
|
||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: moko-platform.Release
|
# INGROUP: moko-platform.Release
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
# PATH: /templates/workflows/universal/pre-release.yml.template
|
# PATH: /templates/workflows/universal/pre-release.yml.template
|
||||||
# VERSION: 05.01.00
|
# VERSION: 05.01.00
|
||||||
# BRIEF: Manual pre-release — builds dev/alpha/beta/rc packages from any branch
|
# BRIEF: Manual pre-release -- builds dev/alpha/beta/rc packages from any branch
|
||||||
|
|
||||||
name: "Universal: Pre-Release"
|
name: "Universal: Pre-Release"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
pull_request:
|
||||||
inputs:
|
types: [closed]
|
||||||
stability:
|
branches:
|
||||||
description: 'Pre-release channel'
|
- dev
|
||||||
required: true
|
workflow_dispatch:
|
||||||
type: choice
|
inputs:
|
||||||
options:
|
stability:
|
||||||
- development
|
description: 'Pre-release channel'
|
||||||
- alpha
|
required: true
|
||||||
- beta
|
type: choice
|
||||||
- release-candidate
|
options:
|
||||||
|
- development
|
||||||
permissions:
|
- alpha
|
||||||
contents: write
|
- beta
|
||||||
|
- release-candidate
|
||||||
env:
|
|
||||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
permissions:
|
||||||
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
contents: write
|
||||||
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
|
||||||
|
env:
|
||||||
jobs:
|
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||||
build:
|
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
||||||
name: "Build Pre-Release (${{ inputs.stability }})"
|
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
||||||
runs-on: release
|
|
||||||
|
jobs:
|
||||||
steps:
|
build:
|
||||||
- name: Checkout
|
name: "Build Pre-Release (${{ inputs.stability || 'development' }})"
|
||||||
uses: actions/checkout@v4
|
runs-on: release
|
||||||
with:
|
if: >-
|
||||||
fetch-depth: 0
|
github.event_name == 'workflow_dispatch' ||
|
||||||
token: ${{ secrets.GA_TOKEN }}
|
(github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev')
|
||||||
|
|
||||||
- name: Setup moko-platform tools
|
steps:
|
||||||
env:
|
- name: Checkout
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN }}
|
uses: actions/checkout@v4
|
||||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
with:
|
||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN }}"}}'
|
fetch-depth: 0
|
||||||
run: |
|
token: ${{ secrets.GA_TOKEN }}
|
||||||
if ! command -v composer &> /dev/null; then
|
|
||||||
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
- name: Setup moko-platform tools
|
||||||
fi
|
env:
|
||||||
git clone --depth 1 --branch main --quiet \
|
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||||
/tmp/moko-platform-api
|
run: |
|
||||||
cd /tmp/moko-platform-api
|
if ! command -v composer &> /dev/null; then
|
||||||
composer install --no-dev --no-interaction --quiet
|
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||||
|
fi
|
||||||
- name: Detect platform
|
git clone --depth 1 --branch main --quiet \
|
||||||
id: platform
|
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||||
run: |
|
/tmp/moko-platform-api
|
||||||
PLATFORM=$(sed -n 's/.*<platform>\([^<]*\)<\/platform>.*/\1/p' .mokogitea/manifest.xml 2>/dev/null | head -1 | tr -d '[:space:]')
|
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet
|
||||||
[ -z "$PLATFORM" ] && PLATFORM=$(sed -n 's/.*<platform>\([^<]*\)<\/platform>.*/\1/p' .gitea/manifest.xml 2>/dev/null | head -1 | tr -d '[:space:]')
|
echo "MOKO_CLI=/tmp/moko-platform-api/cli" >> "$GITHUB_ENV"
|
||||||
[ -z "$PLATFORM" ] && PLATFORM="generic"
|
|
||||||
echo "platform=$PLATFORM" >> "$GITHUB_OUTPUT"
|
- name: Detect platform
|
||||||
|
id: platform
|
||||||
- name: Resolve metadata and bump version
|
run: |
|
||||||
id: meta
|
php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
||||||
run: |
|
|
||||||
CLI="/tmp/moko-platform-api/cli"
|
- name: Resolve metadata and bump version
|
||||||
STABILITY="${{ inputs.stability }}"
|
id: meta
|
||||||
|
run: |
|
||||||
case "$STABILITY" in
|
STABILITY="${{ inputs.stability || 'development' }}"
|
||||||
development) SUFFIX="-dev"; TAG="development" ;;
|
|
||||||
alpha) SUFFIX="-alpha"; TAG="alpha" ;;
|
case "$STABILITY" in
|
||||||
beta) SUFFIX="-beta"; TAG="beta" ;;
|
development) SUFFIX="-dev"; TAG="development" ;;
|
||||||
release-candidate) SUFFIX="-rc"; TAG="release-candidate" ;;
|
alpha) SUFFIX="-alpha"; TAG="alpha" ;;
|
||||||
esac
|
beta) SUFFIX="-beta"; TAG="beta" ;;
|
||||||
|
release-candidate) SUFFIX="-rc"; TAG="release-candidate" ;;
|
||||||
# Bump patch version via CLI
|
esac
|
||||||
CURRENT=$(php $CLI/version_read.php --path . 2>/dev/null)
|
|
||||||
[ -z "$CURRENT" ] && CURRENT="00.00.00"
|
# Read current version (bump already handled by push workflow)
|
||||||
php $CLI/version_bump.php --path .
|
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null)
|
||||||
VERSION=$(php $CLI/version_read.php --path . 2>/dev/null)
|
[ -z "$VERSION" ] && VERSION="00.00.01"
|
||||||
echo "Bumping: ${CURRENT} → ${VERSION} (patch)"
|
|
||||||
|
php ${MOKO_CLI}/version_set_platform.php \
|
||||||
# Set platform-specific version with stability suffix
|
--path . --version "$VERSION" --branch "${{ github.ref_name }}" 2>/dev/null || true
|
||||||
php $CLI/version_set_platform.php \
|
|
||||||
--path . --version "$VERSION" --stability "$STABILITY" --branch "${{ github.ref_name }}"
|
# Verify version consistency across all files
|
||||||
|
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||||
# Commit version bump
|
|
||||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
# Commit version bump
|
||||||
git config --local user.name "gitea-actions[bot]"
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
git remote set-url origin "https://jmiller:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
git config --local user.name "gitea-actions[bot]"
|
||||||
git add -A
|
git remote set-url origin "https://jmiller:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
git diff --cached --quiet || {
|
git add -A
|
||||||
git commit -m "chore(version): bump ${CURRENT} → ${VERSION}${SUFFIX} [skip ci]"
|
git diff --cached --quiet || {
|
||||||
git push origin HEAD 2>&1
|
git commit -m "chore(version): pre-release bump to ${VERSION} [skip ci]"
|
||||||
}
|
git push origin HEAD 2>&1
|
||||||
|
}
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
# Auto-detect element via manifest_element.php
|
||||||
echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT"
|
php ${MOKO_CLI}/manifest_element.php \
|
||||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
--path . --version "$VERSION" --stability "$STABILITY" \
|
||||||
|
--repo "${GITEA_REPO}" --github-output
|
||||||
- name: Build package
|
|
||||||
id: package
|
# Read back element outputs
|
||||||
run: |
|
EXT_ELEMENT=$(grep '^ext_element=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2)
|
||||||
CLI="/tmp/moko-platform-api/cli"
|
ZIP_NAME=$(grep '^zip_name=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2)
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
[ -z "$EXT_ELEMENT" ] && EXT_ELEMENT=$(echo "${GITEA_REPO}" | tr '[:upper:]' '[:lower:]' | tr -d ' -')
|
||||||
SUFFIX="${{ steps.meta.outputs.suffix }}"
|
[ -z "$ZIP_NAME" ] && ZIP_NAME="${EXT_ELEMENT}-${VERSION}${SUFFIX}.zip"
|
||||||
|
|
||||||
# Build ZIP + tar.gz via CLI (handles type prefix, excludes, multi-extension packages)
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
php $CLI/package_build.php \
|
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
||||||
--path . \
|
echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT"
|
||||||
--version "${VERSION}${SUFFIX}" \
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
--output-dir build \
|
echo "zip_name=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
--github-output
|
echo "ext_element=${EXT_ELEMENT}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Create release and upload
|
echo "=== Pre-Release: ${EXT_ELEMENT} ${VERSION}${SUFFIX} ==="
|
||||||
run: |
|
|
||||||
CLI="/tmp/moko-platform-api/cli"
|
- name: Create release
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
id: release
|
||||||
SUFFIX="${{ steps.meta.outputs.suffix }}"
|
run: |
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
EXT_ELEMENT="${{ steps.package.outputs.ext_element }}"
|
php ${MOKO_CLI}/release_create.php \
|
||||||
[ -z "$EXT_ELEMENT" ] && EXT_ELEMENT=$(echo "${GITEA_REPO}" | tr '[:upper:]' '[:lower:]' | tr -d ' -')
|
--path . --version "$VERSION" --tag "$TAG" \
|
||||||
|
--token "${{ secrets.GA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
--repo "${GITEA_REPO}" --branch dev --prerelease
|
||||||
ZIP_PATH="${{ steps.package.outputs.zip_path }}"
|
|
||||||
TAR_PATH="${{ steps.package.outputs.tar_path }}"
|
- name: Build package and upload
|
||||||
|
id: package
|
||||||
# Create release
|
run: |
|
||||||
php $CLI/release_manage.php \
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
--action create \
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
--tag "$TAG" \
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
--name "${EXT_ELEMENT} ${VERSION}${SUFFIX} (${STABILITY})" \
|
php ${MOKO_CLI}/release_package.php \
|
||||||
--body "## ${VERSION}${SUFFIX} ($(date +%Y-%m-%d))\n**Channel:** ${STABILITY}\n**SHA-256:** \`${SHA256}\`" \
|
--path . --version "$VERSION" --tag "$TAG" \
|
||||||
--target "${{ github.ref_name }}" \
|
--token "${{ secrets.GA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
--token "${{ secrets.GA_TOKEN }}" \
|
--repo "${GITEA_REPO}" --output /tmp || true
|
||||||
--api-base "$API_BASE"
|
|
||||||
|
- name: Update updates.xml
|
||||||
# Upload assets
|
if: steps.platform.outputs.platform == 'joomla'
|
||||||
FILES="${ZIP_PATH}"
|
run: |
|
||||||
[ -f "$TAR_PATH" ] && FILES="${FILES},${TAR_PATH}"
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
php $CLI/release_manage.php \
|
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||||
--action upload \
|
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||||
--tag "$TAG" \
|
|
||||||
--files "$FILES" \
|
if [ ! -f "updates.xml" ]; then
|
||||||
--token "${{ secrets.GA_TOKEN }}" \
|
echo "No updates.xml -- skipping"
|
||||||
--api-base "$API_BASE"
|
exit 0
|
||||||
|
fi
|
||||||
- name: Update updates.xml
|
|
||||||
if: steps.platform.outputs.platform == 'joomla'
|
SHA_FLAG=""
|
||||||
run: |
|
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
||||||
CLI="/tmp/moko-platform-api/cli"
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
php ${MOKO_CLI}/updates_xml_build.php \
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
--path . --version "${VERSION}" --stability "${STABILITY}" \
|
||||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
||||||
|
${SHA_FLAG}
|
||||||
# Map stability names
|
|
||||||
case "$STABILITY" in
|
# Commit and push
|
||||||
release-candidate) CLI_STABILITY="rc" ;;
|
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||||
*) CLI_STABILITY="$STABILITY" ;;
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
esac
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
git add updates.xml
|
||||||
# Generate updates.xml with stability-suffixed versions
|
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
||||||
php $CLI/updates_xml_build.php \
|
git push origin HEAD 2>&1 || echo "WARNING: push failed"
|
||||||
--path . \
|
fi
|
||||||
--version "$VERSION" \
|
|
||||||
--stability "$CLI_STABILITY" \
|
- name: "Sync updates.xml to all branches"
|
||||||
--sha "$SHA256" \
|
if: steps.platform.outputs.platform == 'joomla'
|
||||||
--gitea-url "${GITEA_URL}" \
|
run: |
|
||||||
--org "${GITEA_ORG}" \
|
CURRENT_BRANCH="${{ github.ref_name }}"
|
||||||
--repo "${GITEA_REPO}"
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
# Commit and push
|
|
||||||
if ! git diff --quiet updates.xml 2>/dev/null; then
|
for BRANCH in main dev; do
|
||||||
git add updates.xml
|
[ "$BRANCH" = "$CURRENT_BRANCH" ] && continue
|
||||||
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
echo "Syncing updates.xml -> ${BRANCH}"
|
||||||
git push origin HEAD 2>&1 || echo "WARNING: push failed"
|
git fetch origin "${BRANCH}" 2>/dev/null || continue
|
||||||
fi
|
git checkout "origin/${BRANCH}" -- updates.xml 2>/dev/null || continue
|
||||||
|
git checkout "${CURRENT_BRANCH}" -- updates.xml
|
||||||
- name: "Sync updates.xml to all branches"
|
if ! git diff --quiet updates.xml 2>/dev/null; then
|
||||||
if: steps.platform.outputs.platform == 'joomla'
|
git add updates.xml
|
||||||
run: |
|
git commit -m "chore: sync updates.xml from ${CURRENT_BRANCH} [skip ci]"
|
||||||
CURRENT_BRANCH="${{ github.ref_name }}"
|
git push origin HEAD:refs/heads/${BRANCH} 2>&1 || echo "WARNING: push to ${BRANCH} failed"
|
||||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
fi
|
||||||
git config --local user.name "gitea-actions[bot]"
|
git checkout "${CURRENT_BRANCH}" 2>/dev/null
|
||||||
|
done
|
||||||
for BRANCH in main dev; do
|
|
||||||
[ "$BRANCH" = "$CURRENT_BRANCH" ] && continue
|
- name: "Delete lesser pre-release channels (cascade)"
|
||||||
echo "Syncing updates.xml → ${BRANCH}"
|
continue-on-error: true
|
||||||
git fetch origin "${BRANCH}" 2>/dev/null || continue
|
run: |
|
||||||
git checkout "origin/${BRANCH}" -- . 2>/dev/null || continue
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
git checkout "${CURRENT_BRANCH}" -- updates.xml
|
TOKEN="${{ secrets.GA_TOKEN }}"
|
||||||
if ! git diff --quiet updates.xml 2>/dev/null; then
|
|
||||||
git add updates.xml
|
php ${MOKO_CLI}/release_cascade.php \
|
||||||
git commit -m "chore: sync updates.xml from ${CURRENT_BRANCH} [skip ci]"
|
--stability "${{ steps.meta.outputs.stability }}" \
|
||||||
git push origin HEAD:refs/heads/${BRANCH} 2>&1 || echo "WARNING: push to ${BRANCH} failed"
|
--token "${TOKEN}" \
|
||||||
fi
|
--api-base "${API_BASE}"
|
||||||
git checkout "${CURRENT_BRANCH}" 2>/dev/null
|
|
||||||
done
|
- name: Summary
|
||||||
|
if: always()
|
||||||
- name: "Delete lesser pre-release channels (cascade)"
|
run: |
|
||||||
continue-on-error: true
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
run: |
|
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
ZIP_NAME="${{ steps.meta.outputs.zip_name }}"
|
||||||
|
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||||
# Map workflow stability names to CLI names
|
echo "## Pre-Release Complete" >> $GITHUB_STEP_SUMMARY
|
||||||
case "$STABILITY" in
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
release-candidate) CLI_STABILITY="rc" ;;
|
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
||||||
*) CLI_STABILITY="$STABILITY" ;;
|
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
||||||
esac
|
echo "| Version | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Channel | ${STABILITY} |" >> $GITHUB_STEP_SUMMARY
|
||||||
php /tmp/moko-platform-api/cli/release_cascade.php \
|
echo "| Package | \`${ZIP_NAME}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
--stability "$CLI_STABILITY" \
|
echo "| SHA-256 | \`${SHA256:-n/a}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
--token "${{ secrets.GA_TOKEN }}" \
|
|
||||||
--api-base "${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
|
|||||||
@@ -0,0 +1,597 @@
|
|||||||
|
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
#
|
||||||
|
# FILE INFORMATION
|
||||||
|
# DEFGROUP: Gitea.Workflow
|
||||||
|
# INGROUP: MokoStandards.Universal
|
||||||
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
|
# PATH: /templates/workflows/update-server.yml
|
||||||
|
# VERSION: 04.07.00
|
||||||
|
# BRIEF: Update server XML feed with stable/rc/beta/alpha/dev entries (universal)
|
||||||
|
#
|
||||||
|
# Writes updates.xml with multiple <update> entries:
|
||||||
|
# - <tag>stable</tag> on push to main (from auto-release)
|
||||||
|
# - <tag>rc</tag> on push to rc/**
|
||||||
|
# - <tag>development</tag> on push to dev or dev/**
|
||||||
|
#
|
||||||
|
# Joomla filters by user's "Minimum Stability" setting.
|
||||||
|
|
||||||
|
name: "Update Server"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
- 'dev/**'
|
||||||
|
- 'alpha/**'
|
||||||
|
- 'beta/**'
|
||||||
|
- 'rc/**'
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'htdocs/**'
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
- 'dev/**'
|
||||||
|
- 'alpha/**'
|
||||||
|
- 'beta/**'
|
||||||
|
- 'rc/**'
|
||||||
|
paths:
|
||||||
|
- 'src/**'
|
||||||
|
- 'htdocs/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
stability:
|
||||||
|
description: 'Stability tag'
|
||||||
|
required: true
|
||||||
|
default: 'development'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- development
|
||||||
|
- alpha
|
||||||
|
- beta
|
||||||
|
- rc
|
||||||
|
- stable
|
||||||
|
|
||||||
|
env:
|
||||||
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
|
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||||
|
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
||||||
|
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-xml:
|
||||||
|
name: Update updates.xml
|
||||||
|
runs-on: release
|
||||||
|
if: >-
|
||||||
|
github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' || github.event_name == 'push'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GA_TOKEN }}
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup moko-platform tools
|
||||||
|
env:
|
||||||
|
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN }}
|
||||||
|
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||||
|
COMPOSER_AUTH: '{"http-basic":{"git.mokoconsulting.tech":{"username":"token","password":"${{ secrets.GA_TOKEN }}"}}}'
|
||||||
|
run: |
|
||||||
|
if ! command -v composer &> /dev/null; then
|
||||||
|
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
if [ -d "/tmp/moko-platform" ]; then
|
||||||
|
echo "moko-platform already available — skipping clone"
|
||||||
|
else
|
||||||
|
git clone --depth 1 --branch main --quiet \
|
||||||
|
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||||
|
/tmp/moko-platform 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
if [ -d "/tmp/moko-platform" ] && [ -f "/tmp/moko-platform/composer.json" ]; then
|
||||||
|
cd /tmp/moko-platform && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Generate updates.xml entry
|
||||||
|
id: update
|
||||||
|
run: |
|
||||||
|
BRANCH="${{ github.ref_name }}"
|
||||||
|
REPO="${{ github.repository }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
VERSION=$(php /tmp/moko-platform/cli/version_read.php --path . 2>/dev/null || echo "0.0.0")
|
||||||
|
|
||||||
|
# Auto-bump patch on all branches (dev, alpha, beta, rc)
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
BUMPED=$(php /tmp/moko-platform/cli/version_bump.php --path . 2>/dev/null || true)
|
||||||
|
if [ -n "$BUMPED" ]; then
|
||||||
|
VERSION=$(php /tmp/moko-platform/cli/version_read.php --path . 2>/dev/null || echo "$VERSION")
|
||||||
|
git add -A
|
||||||
|
git commit -m "chore(version): auto-bump patch ${VERSION} [skip ci]" \
|
||||||
|
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>" 2>/dev/null || true
|
||||||
|
git push 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine stability from branch or input
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
STABILITY="${{ inputs.stability }}"
|
||||||
|
elif [[ "$BRANCH" == rc/* ]]; then
|
||||||
|
STABILITY="rc"
|
||||||
|
elif [[ "$BRANCH" == beta/* ]]; then
|
||||||
|
STABILITY="beta"
|
||||||
|
elif [[ "$BRANCH" == alpha/* ]]; then
|
||||||
|
STABILITY="alpha"
|
||||||
|
elif [[ "$BRANCH" == dev/* ]] || [[ "$BRANCH" == "dev" ]]; then
|
||||||
|
STABILITY="development"
|
||||||
|
else
|
||||||
|
STABILITY="stable"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# Parse manifest (portable — no grep -P)
|
||||||
|
MANIFEST=$(find . -maxdepth 3 -name "*.xml" ! -path "./.git/*" ! -path "./build/*" -exec grep -l '<extension' {} \; 2>/dev/null | head -1)
|
||||||
|
if [ -z "$MANIFEST" ]; then
|
||||||
|
echo "No Joomla manifest found — skipping"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract fields using sed (works on all runners)
|
||||||
|
EXT_NAME=$(sed -n 's/.*<name>\([^<]*\)<\/name>.*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
EXT_TYPE=$(sed -n 's/.*<extension[^>]*type="\([^"]*\)".*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
EXT_ELEMENT=$(sed -n 's/.*<element>\([^<]*\)<\/element>.*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
EXT_CLIENT=$(sed -n 's/.*<extension[^>]*client="\([^"]*\)".*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
EXT_FOLDER=$(sed -n 's/.*<extension[^>]*group="\([^"]*\)".*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
EXT_VERSION=$(sed -n 's/.*<version>\([^<]*\)<\/version>.*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
TARGET_PLATFORM=$(sed -n 's/.*\(<targetplatform[^/]*\/>\).*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
PHP_MINIMUM=$(sed -n 's/.*<php_minimum>\([^<]*\)<\/php_minimum>.*/\1/p' "$MANIFEST" | head -1)
|
||||||
|
|
||||||
|
# Fallbacks
|
||||||
|
[ -z "$EXT_NAME" ] && EXT_NAME="${{ github.event.repository.name }}"
|
||||||
|
[ -z "$EXT_TYPE" ] && EXT_TYPE="component"
|
||||||
|
|
||||||
|
# Derive element if not in manifest: try XML filename, then repo name
|
||||||
|
if [ -z "$EXT_ELEMENT" ]; then
|
||||||
|
EXT_ELEMENT=$(basename "$MANIFEST" .xml | tr '[:upper:]' '[:lower:]')
|
||||||
|
case "$EXT_ELEMENT" in
|
||||||
|
templatedetails|manifest|*.xml) EXT_ELEMENT=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]' | tr -d ' -') ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use manifest version if README version is empty
|
||||||
|
[ "$VERSION" = "0.0.0" ] && [ -n "$EXT_VERSION" ] && VERSION="$EXT_VERSION"
|
||||||
|
|
||||||
|
[ -z "$TARGET_PLATFORM" ] && TARGET_PLATFORM=$(printf '<targetplatform name="joomla" version="((5.[0-9])|(6.[0-9]))" %s>' "/")
|
||||||
|
|
||||||
|
# Joomla requires <client> on ALL extension types for update matching
|
||||||
|
if [ -n "$EXT_CLIENT" ]; then
|
||||||
|
CLIENT_TAG="<client>${EXT_CLIENT}</client>"
|
||||||
|
else
|
||||||
|
CLIENT_TAG="<client>site</client>"
|
||||||
|
fi
|
||||||
|
|
||||||
|
FOLDER_TAG=""
|
||||||
|
[ -n "$EXT_FOLDER" ] && [ "$EXT_TYPE" = "plugin" ] && FOLDER_TAG="<folder>${EXT_FOLDER}</folder>"
|
||||||
|
|
||||||
|
PHP_TAG=""
|
||||||
|
[ -n "$PHP_MINIMUM" ] && PHP_TAG="<php_minimum>${PHP_MINIMUM}</php_minimum>"
|
||||||
|
|
||||||
|
# Version suffix for non-stable
|
||||||
|
DISPLAY_VERSION="$VERSION"
|
||||||
|
case "$STABILITY" in
|
||||||
|
development) DISPLAY_VERSION="${VERSION}-dev" ;;
|
||||||
|
alpha) DISPLAY_VERSION="${VERSION}-alpha" ;;
|
||||||
|
beta) DISPLAY_VERSION="${VERSION}-beta" ;;
|
||||||
|
rc) DISPLAY_VERSION="${VERSION}-rc" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
MAJOR=$(echo "$VERSION" | awk -F. '{print $1}')
|
||||||
|
|
||||||
|
# Each stability level has its own release tag
|
||||||
|
case "$STABILITY" in
|
||||||
|
development) RELEASE_TAG="development" ;;
|
||||||
|
alpha) RELEASE_TAG="alpha" ;;
|
||||||
|
beta) RELEASE_TAG="beta" ;;
|
||||||
|
rc) RELEASE_TAG="release-candidate" ;;
|
||||||
|
*) RELEASE_TAG="v${MAJOR}" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
PACKAGE_NAME="${EXT_ELEMENT}-${DISPLAY_VERSION}.zip"
|
||||||
|
DOWNLOAD_URL="${GITEA_URL}/${GITEA_ORG}/${GITEA_REPO}/releases/download/${RELEASE_TAG}/${PACKAGE_NAME}"
|
||||||
|
INFO_URL="${GITEA_URL}/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
|
||||||
|
# -- Build install packages and upload to release --------------------
|
||||||
|
php /tmp/moko-platform/cli/release_package.php \
|
||||||
|
--path . --version "${DISPLAY_VERSION}" --tag "${RELEASE_TAG}" \
|
||||||
|
--token "${{ secrets.GA_TOKEN }}" --api-base "${API_BASE}" \
|
||||||
|
--repo "${GITEA_REPO}" --output /tmp 2>&1 || true
|
||||||
|
|
||||||
|
echo "Package built and uploaded for ${RELEASE_TAG}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
# -- Build the new entry (canonical format matching release.yml) --
|
||||||
|
NEW_ENTRY=""
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <update>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <name>${EXT_NAME}</name>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <description>${EXT_NAME} ${STABILITY} build.</description>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <element>${EXT_ELEMENT}</element>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <type>${EXT_TYPE}</type>\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} <version>${VERSION}</version>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <creationDate>$(date +%Y-%m-%d)</creationDate>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <infourl title='${EXT_NAME}'>https://git.mokoconsulting.tech/${GITEA_ORG}/${GITEA_REPO}/releases/tag/${RELEASE_TAG}</infourl>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <downloads>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <downloadurl type='full' format='zip'>${DOWNLOAD_URL}</downloadurl>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} </downloads>\n"
|
||||||
|
[ -n "$SHA256" ] && NEW_ENTRY="${NEW_ENTRY} <sha256>${SHA256}</sha256>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <tags><tag>${STABILITY}</tag></tags>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <maintainer>Moko Consulting</maintainer>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <maintainerurl>https://mokoconsulting.tech</maintainerurl>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} <targetplatform name='joomla' version='(5|6).*'/>\n"
|
||||||
|
[ -n "$PHP_MINIMUM" ] && NEW_ENTRY="${NEW_ENTRY} <php_minimum>${PHP_MINIMUM}</php_minimum>\n"
|
||||||
|
NEW_ENTRY="${NEW_ENTRY} </update>"
|
||||||
|
|
||||||
|
# -- Write new entry to temp file --------------------------------
|
||||||
|
printf '%b' "$NEW_ENTRY" > /tmp/new_entry.xml
|
||||||
|
|
||||||
|
# -- 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
|
||||||
|
key="${entry%%:*}"
|
||||||
|
vals="${entry#*:}"
|
||||||
|
if [ "$key" = "${STABILITY}" ]; then
|
||||||
|
TARGETS="$vals"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[ -z "$TARGETS" ] && TARGETS="${STABILITY}"
|
||||||
|
|
||||||
|
echo "Cascade: ${STABILITY} → ${TARGETS}"
|
||||||
|
|
||||||
|
# Create updates.xml if missing
|
||||||
|
if [ ! -f "updates.xml" ]; then
|
||||||
|
printf '%s\n' "<?xml version='1.0' encoding='UTF-8'?>" > updates.xml
|
||||||
|
printf '%s\n' "<!-- Copyright (C) $(date +%Y) Moko Consulting -->" >> updates.xml
|
||||||
|
printf '%s\n' "<updates>" >> updates.xml
|
||||||
|
printf '%s\n' "</updates>" >> 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(",")
|
||||||
|
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's name
|
||||||
|
new_entry = re.sub(r"<tag>[^<]*</tag>", f"<tag>{tag}</tag>", new_entry_template)
|
||||||
|
|
||||||
|
# Try to find existing block (handles both single-line and multi-line <tags>)
|
||||||
|
block_pattern = r"(<update>(?:(?!</update>).)*?<tag>" + re.escape(tag) + r"</tag>.*?</update>)"
|
||||||
|
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>{tag}</tag> → {version}")
|
||||||
|
else:
|
||||||
|
# Create — insert before </updates>
|
||||||
|
content = content.replace("</updates>", "\n" + new_entry.strip() + "\n\n</updates>")
|
||||||
|
print(f" CREATED: <tag>{tag}</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
|
||||||
|
|
||||||
|
# Commit
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
git add updates.xml
|
||||||
|
git diff --cached --quiet || {
|
||||||
|
git commit -m "chore: update updates.xml (${STABILITY}: ${DISPLAY_VERSION}) [skip ci]" \
|
||||||
|
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
||||||
|
git push
|
||||||
|
}
|
||||||
|
|
||||||
|
# -- Sync updates.xml to main (for non-main branches) ----------------------
|
||||||
|
- name: Sync updates.xml to main
|
||||||
|
if: github.ref_name != 'main'
|
||||||
|
run: |
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
GA_TOKEN="${{ secrets.GA_TOKEN }}"
|
||||||
|
|
||||||
|
FILE_SHA=$(curl -sf -H "Authorization: token ${GA_TOKEN}" \
|
||||||
|
"${API_BASE}/contents/updates.xml?ref=main" | python3 -c "import sys,json; print(json.load(sys.stdin).get('sha',''))" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ -n "$FILE_SHA" ] && [ -f "updates.xml" ]; then
|
||||||
|
python3 -c "
|
||||||
|
import base64, json, urllib.request, sys
|
||||||
|
with open('updates.xml', 'rb') as f:
|
||||||
|
content = base64.b64encode(f.read()).decode()
|
||||||
|
payload = json.dumps({
|
||||||
|
'content': content,
|
||||||
|
'sha': '${FILE_SHA}',
|
||||||
|
'message': 'chore: sync updates.xml from ${STABILITY} [skip ci]',
|
||||||
|
'branch': 'main'
|
||||||
|
}).encode()
|
||||||
|
req = urllib.request.Request(
|
||||||
|
'${API_BASE}/contents/updates.xml',
|
||||||
|
data=payload, method='PUT',
|
||||||
|
headers={
|
||||||
|
'Authorization': 'token ${GA_TOKEN}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
})
|
||||||
|
try:
|
||||||
|
urllib.request.urlopen(req)
|
||||||
|
print('updates.xml synced to main')
|
||||||
|
except Exception as e:
|
||||||
|
print(f'ERROR: failed to sync updates.xml to main: {e}', file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
" \
|
||||||
|
&& echo "updates.xml synced to main (${STABILITY})" >> $GITHUB_STEP_SUMMARY \
|
||||||
|
|| echo "::error::failed to sync updates.xml to main" >> $GITHUB_STEP_SUMMARY
|
||||||
|
else
|
||||||
|
echo "::error::could not get updates.xml SHA from main — file may not exist on main yet" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: SFTP deploy to dev server
|
||||||
|
if: contains(github.ref, 'dev/') || github.ref == 'refs/heads/dev'
|
||||||
|
env:
|
||||||
|
DEV_HOST: ${{ vars.DEV_FTP_HOST }}
|
||||||
|
DEV_PATH: ${{ vars.DEV_FTP_PATH }}
|
||||||
|
DEV_SUFFIX: ${{ vars.DEV_FTP_SUFFIX }}
|
||||||
|
DEV_USER: ${{ vars.DEV_FTP_USERNAME }}
|
||||||
|
DEV_PORT: ${{ vars.DEV_FTP_PORT }}
|
||||||
|
DEV_KEY: ${{ secrets.DEV_FTP_KEY }}
|
||||||
|
DEV_PASS: ${{ secrets.DEV_FTP_PASSWORD }}
|
||||||
|
run: |
|
||||||
|
# -- Permission check: admin or maintain role required --------
|
||||||
|
ACTOR="${{ github.actor }}"
|
||||||
|
REPO="${{ github.repository }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
|
||||||
|
PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" \
|
||||||
|
"${API_BASE}/collaborators/${ACTOR}/permission" 2>/dev/null | \
|
||||||
|
python3 -c "import sys,json; print(json.load(sys.stdin).get('permission','read'))" 2>/dev/null || echo "read")
|
||||||
|
case "$PERMISSION" in
|
||||||
|
admin|maintain|write) ;;
|
||||||
|
*)
|
||||||
|
echo "Deploy denied: ${ACTOR} has '${PERMISSION}' — requires admin, maintain, or write"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -z "$DEV_HOST" ] || [ -z "$DEV_PATH" ] && { echo "DEV FTP not configured — skipping SFTP"; exit 0; }
|
||||||
|
|
||||||
|
SOURCE_DIR="src"
|
||||||
|
[ ! -d "$SOURCE_DIR" ] && SOURCE_DIR="htdocs"
|
||||||
|
[ ! -d "$SOURCE_DIR" ] && exit 0
|
||||||
|
|
||||||
|
PORT="${DEV_PORT:-22}"
|
||||||
|
REMOTE="${DEV_PATH%/}"
|
||||||
|
[ -n "$DEV_SUFFIX" ] && REMOTE="${REMOTE}/${DEV_SUFFIX#/}"
|
||||||
|
|
||||||
|
printf '{"host":"%s","port":%s,"username":"%s","remotePath":"%s"' \
|
||||||
|
"$DEV_HOST" "$PORT" "$DEV_USER" "$REMOTE" > /tmp/sftp-config.json
|
||||||
|
if [ -n "$DEV_KEY" ]; then
|
||||||
|
echo "$DEV_KEY" > /tmp/deploy_key && chmod 600 /tmp/deploy_key
|
||||||
|
printf ',"privateKeyPath":"/tmp/deploy_key"}' >> /tmp/sftp-config.json
|
||||||
|
else
|
||||||
|
printf ',"password":"%s"}' "$DEV_PASS" >> /tmp/sftp-config.json
|
||||||
|
fi
|
||||||
|
|
||||||
|
PLATFORM=$(php /tmp/moko-platform/cli/platform_detect.php --path . 2>/dev/null || true)
|
||||||
|
if [ "$PLATFORM" = "waas-component" ] && [ -f "/tmp/moko-platform/deploy/deploy-joomla.php" ]; then
|
||||||
|
php /tmp/moko-platform/deploy/deploy-joomla.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
||||||
|
elif [ -f "/tmp/moko-platform/deploy/deploy-sftp.php" ]; then
|
||||||
|
php /tmp/moko-platform/deploy/deploy-sftp.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
||||||
|
fi
|
||||||
|
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
||||||
|
echo "SFTP deploy to dev complete" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
- name: Validate updates.xml integrity
|
||||||
|
run: |
|
||||||
|
ERRORS=0
|
||||||
|
|
||||||
|
if [ ! -f "updates.xml" ]; then
|
||||||
|
echo "::error::updates.xml not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Well-formed XML
|
||||||
|
if ! python3 -c "import xml.etree.ElementTree as ET; ET.parse('updates.xml')" 2>/dev/null; then
|
||||||
|
echo "::error::updates.xml is not valid XML"
|
||||||
|
ERRORS=$((ERRORS+1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
python3 << 'PYEOF'
|
||||||
|
import xml.etree.ElementTree as ET, sys, re, os
|
||||||
|
|
||||||
|
tree = ET.parse("updates.xml")
|
||||||
|
root = tree.getroot()
|
||||||
|
updates = root.findall("update")
|
||||||
|
errors = 0
|
||||||
|
warnings = 0
|
||||||
|
seen_tags = set()
|
||||||
|
|
||||||
|
# All 5 channels MUST be present
|
||||||
|
REQUIRED_CHANNELS = {"stable", "rc", "beta", "alpha", "dev"}
|
||||||
|
VALID_TAGS = REQUIRED_CHANNELS | {"development"} # accept legacy alias
|
||||||
|
REPO = os.environ.get("GITEA_REPO", "")
|
||||||
|
ORG = os.environ.get("GITEA_ORG", "MokoConsulting")
|
||||||
|
REPO_BASE = f"https://git.mokoconsulting.tech/{ORG}/"
|
||||||
|
|
||||||
|
# Gitea release tag names per channel (Moko standard)
|
||||||
|
RELEASE_TAG_MAP = {
|
||||||
|
"stable": "stable",
|
||||||
|
"rc": "release-candidate",
|
||||||
|
"beta": "beta",
|
||||||
|
"alpha": "alpha",
|
||||||
|
"dev": "development",
|
||||||
|
"development": "development",
|
||||||
|
}
|
||||||
|
|
||||||
|
# Joomla update XML required fields per
|
||||||
|
# https://docs.joomla.org/Deploying_an_Update_Server
|
||||||
|
REQUIRED_FIELDS = ["name", "element", "type", "version", "infourl"]
|
||||||
|
|
||||||
|
for i, u in enumerate(updates):
|
||||||
|
tag_el = u.find("tags/tag")
|
||||||
|
tag = tag_el.text.strip() if tag_el is not None and tag_el.text else None
|
||||||
|
label = f"Entry {i+1} (<tag>{tag or '?'}</tag>)"
|
||||||
|
|
||||||
|
# -- Required Joomla fields --
|
||||||
|
for field in REQUIRED_FIELDS:
|
||||||
|
el = u.find(field)
|
||||||
|
if el is None or not (el.text or "").strip():
|
||||||
|
print(f"::error::{label}: missing required <{field}>")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- <downloads><downloadurl> --
|
||||||
|
dl = u.find("downloads/downloadurl")
|
||||||
|
if dl is None or not (dl.text or "").strip():
|
||||||
|
print(f"::error::{label}: missing <downloads><downloadurl>")
|
||||||
|
errors += 1
|
||||||
|
else:
|
||||||
|
dl_url = dl.text.strip()
|
||||||
|
# Must point to org repo
|
||||||
|
if REPO_BASE not in dl_url:
|
||||||
|
print(f"::error::{label}: download URL not under {REPO_BASE}: {dl_url}")
|
||||||
|
errors += 1
|
||||||
|
# Must end in .zip
|
||||||
|
if not dl_url.endswith(".zip"):
|
||||||
|
print(f"::error::{label}: download URL must end in .zip: {dl_url}")
|
||||||
|
errors += 1
|
||||||
|
# Must use correct Gitea release tag in path
|
||||||
|
if tag and tag in RELEASE_TAG_MAP:
|
||||||
|
expected_tag = RELEASE_TAG_MAP[tag]
|
||||||
|
if f"/download/{expected_tag}/" not in dl_url:
|
||||||
|
print(f"::error::{label}: download URL should contain /download/{expected_tag}/ but got: {dl_url}")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- <client> (required for Joomla to match update) --
|
||||||
|
client = u.find("client")
|
||||||
|
if client is None or not (client.text or "").strip():
|
||||||
|
print(f"::error::{label}: missing <client> (required for Joomla update matching)")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- <targetplatform> --
|
||||||
|
tp = u.find("targetplatform")
|
||||||
|
if tp is None:
|
||||||
|
print(f"::error::{label}: missing <targetplatform>")
|
||||||
|
errors += 1
|
||||||
|
else:
|
||||||
|
tp_name = tp.get("name", "")
|
||||||
|
tp_ver = tp.get("version", "")
|
||||||
|
if tp_name != "joomla":
|
||||||
|
print(f"::error::{label}: targetplatform name should be 'joomla', got '{tp_name}'")
|
||||||
|
errors += 1
|
||||||
|
if not tp_ver:
|
||||||
|
print(f"::error::{label}: targetplatform missing version regex")
|
||||||
|
errors += 1
|
||||||
|
elif "5" not in tp_ver or "6" not in tp_ver:
|
||||||
|
print(f"::warning::{label}: targetplatform version may not cover Joomla 5+6: {tp_ver}")
|
||||||
|
warnings += 1
|
||||||
|
|
||||||
|
# -- <type> must be valid Joomla type --
|
||||||
|
type_el = u.find("type")
|
||||||
|
if type_el is not None and type_el.text:
|
||||||
|
valid_types = {"component", "module", "plugin", "template", "library", "package", "file"}
|
||||||
|
if type_el.text.strip() not in valid_types:
|
||||||
|
print(f"::error::{label}: invalid type '{type_el.text}' (expected: {valid_types})")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- <version> format (XX.YY.ZZ with optional suffix) --
|
||||||
|
ver_el = u.find("version")
|
||||||
|
if ver_el is not None and ver_el.text:
|
||||||
|
if not re.match(r"^\d{2}\.\d{2}\.\d{2}(-\w+)?$", ver_el.text.strip()):
|
||||||
|
print(f"::warning::{label}: version '{ver_el.text}' does not match XX.YY.ZZ format")
|
||||||
|
warnings += 1
|
||||||
|
|
||||||
|
# -- <maintainer> and <maintainerurl> --
|
||||||
|
for field in ["maintainer", "maintainerurl"]:
|
||||||
|
el = u.find(field)
|
||||||
|
if el is None or not (el.text or "").strip():
|
||||||
|
print(f"::warning::{label}: missing <{field}>")
|
||||||
|
warnings += 1
|
||||||
|
|
||||||
|
# -- Valid stability tag --
|
||||||
|
if tag is None:
|
||||||
|
print(f"::error::{label}: missing <tags><tag>")
|
||||||
|
errors += 1
|
||||||
|
elif tag not in VALID_TAGS:
|
||||||
|
print(f"::error::{label}: invalid tag '{tag}' (expected: {VALID_TAGS})")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- Duplicate tag check --
|
||||||
|
norm_tag = "dev" if tag == "development" else tag
|
||||||
|
if norm_tag in seen_tags:
|
||||||
|
print(f"::error::{label}: duplicate channel '{tag}'")
|
||||||
|
errors += 1
|
||||||
|
if norm_tag:
|
||||||
|
seen_tags.add(norm_tag)
|
||||||
|
|
||||||
|
# -- All 5 channels must exist --
|
||||||
|
missing = REQUIRED_CHANNELS - seen_tags
|
||||||
|
if missing:
|
||||||
|
print(f"::error::Missing required update channels: {', '.join(sorted(missing))}")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- Version ordering: higher stability must not exceed dev version --
|
||||||
|
channel_versions = {}
|
||||||
|
for u in updates:
|
||||||
|
tag_el = u.find("tags/tag")
|
||||||
|
ver_el = u.find("version")
|
||||||
|
if tag_el is not None and ver_el is not None and tag_el.text and ver_el.text:
|
||||||
|
norm = "dev" if tag_el.text.strip() == "development" else tag_el.text.strip()
|
||||||
|
# Strip suffix for comparison (01.00.18-dev -> 01.00.18)
|
||||||
|
base_ver = re.sub(r"-\w+$", "", ver_el.text.strip())
|
||||||
|
channel_versions[norm] = base_ver
|
||||||
|
|
||||||
|
# Cascade check: dev >= alpha >= beta >= rc >= stable
|
||||||
|
ORDER = ["dev", "alpha", "beta", "rc", "stable"]
|
||||||
|
for j in range(1, len(ORDER)):
|
||||||
|
current = ORDER[j]
|
||||||
|
previous = ORDER[j - 1]
|
||||||
|
if current in channel_versions and previous in channel_versions:
|
||||||
|
if channel_versions[current] > channel_versions[previous]:
|
||||||
|
print(f"::error::{current} version ({channel_versions[current]}) is ahead of {previous} ({channel_versions[previous]})")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
|
# -- Summary --
|
||||||
|
print(f"\nupdates.xml validation: {len(updates)} entries, {errors} error(s), {warnings} warning(s)")
|
||||||
|
if errors > 0:
|
||||||
|
sys.exit(1)
|
||||||
|
PYEOF
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
echo "## Joomla Update Server" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Stability | \`${STABILITY}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Version | \`${DISPLAY_VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Element | \`${EXT_ELEMENT}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Download | [ZIP](${DOWNLOAD_URL}) |" >> $GITHUB_STEP_SUMMARY
|
||||||
Reference in New Issue
Block a user