Compare commits
51 Commits
main
..
development
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b57661e95 | |||
| 9c543e2f65 | |||
| 74b14d9aff | |||
| 088b987da0 | |||
| 967cf3de3f | |||
| f9ae5fc336 | |||
| 19c270d7a8 | |||
| c77bbb778d | |||
| d729171108 | |||
| 9baab2bb28 | |||
| cefd43b365 | |||
| 9918edda02 | |||
| c12d9e055f | |||
| 0e3a338f1f | |||
| 56eaf5b99e | |||
| 0f1c7b2f3d | |||
| 13809d3f7f | |||
| ca68991ba5 | |||
| ec33050edf | |||
| 6a48e79264 | |||
| 72fd5adbea | |||
| 63e4915631 | |||
| 3c8f032c82 | |||
| be61d7ddca | |||
| f10e6d9526 | |||
| f037530651 | |||
| 1c92bbea8b | |||
| c0fd371720 | |||
| 2f5d45e847 | |||
| 39ecdffe2f | |||
| 37050cc04d | |||
| b842809353 | |||
| 249e113593 | |||
| a4810f4873 | |||
| 8481577fd0 | |||
| 4a7a27982e | |||
| 7ba14f702a | |||
| 4c178c5693 | |||
| c9a7c0eec2 | |||
| e752dc303a | |||
| 3865533954 | |||
| 38a710318c | |||
| 374275ccb7 | |||
| 1e552fe4bd | |||
| 561e4bb7de | |||
| 1dcb02ba1a | |||
| 7830da21dd | |||
| 6db4a7435f | |||
| 1b07ef4642 | |||
| 2508a47e33 | |||
| ce839f0f29 |
@@ -1,251 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: moko-platform.Automation
|
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
|
||||||
# PATH: /.gitea/workflows/branch-protection.yml
|
|
||||||
# BRIEF: Apply standardised branch protection rules to all governed repositories
|
|
||||||
#
|
|
||||||
# +========================================================================+
|
|
||||||
# | BRANCH PROTECTION SETUP |
|
|
||||||
# +========================================================================+
|
|
||||||
# | |
|
|
||||||
# | Applies protection rules for: main, dev, rc, beta, alpha |
|
|
||||||
# | |
|
|
||||||
# | main — Require PR, block rejected reviews, no force push |
|
|
||||||
# | dev — Allow push, no force push, no delete |
|
|
||||||
# | rc — Allow push, no force push, no delete |
|
|
||||||
# | beta — Allow push, no force push, no delete |
|
|
||||||
# | alpha — Allow push, no force push, no delete |
|
|
||||||
# | |
|
|
||||||
# | jmiller has override authority on all branches. |
|
|
||||||
# | |
|
|
||||||
# +========================================================================+
|
|
||||||
|
|
||||||
name: Branch Protection Setup
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: '0 2 * * 1' # Weekly Monday 02:00 UTC
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
dry_run:
|
|
||||||
description: 'Preview mode (no changes)'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
repos:
|
|
||||||
description: 'Comma-separated repo names (empty = all governed repos)'
|
|
||||||
required: false
|
|
||||||
type: string
|
|
||||||
default: ''
|
|
||||||
|
|
||||||
env:
|
|
||||||
GITEA_URL: https://git.mokoconsulting.tech
|
|
||||||
GITEA_ORG: MokoConsulting
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
protect:
|
|
||||||
name: Apply Branch Protection Rules
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Determine target repos
|
|
||||||
id: repos
|
|
||||||
env:
|
|
||||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
|
||||||
run: |
|
|
||||||
API="${GITEA_URL}/api/v1"
|
|
||||||
|
|
||||||
# Platform/standards/infra repos to exclude
|
|
||||||
EXCLUDE="gitea-org-config org-profile gitea-private .mokogitea-private MokoStandards moko-platform MokoTesting"
|
|
||||||
EXCLUDE="$EXCLUDE MokoStandards-Template-Client MokoStandards-Template-Dolibarr MokoStandards-Template-Generic MokoStandards-Template-Joomla MokoDoliProjTemplate"
|
|
||||||
|
|
||||||
if [ -n "${{ inputs.repos }}" ]; then
|
|
||||||
# User-specified repos
|
|
||||||
REPOS=$(echo "${{ inputs.repos }}" | tr ',' ' ')
|
|
||||||
else
|
|
||||||
# Fetch all org repos
|
|
||||||
PAGE=1
|
|
||||||
REPOS=""
|
|
||||||
while true; do
|
|
||||||
BATCH=$(curl -sS \
|
|
||||||
-H "Authorization: token ${GA_TOKEN}" \
|
|
||||||
"${API}/orgs/${GITEA_ORG}/repos?page=${PAGE}&limit=50" \
|
|
||||||
| jq -r '.[].name // empty')
|
|
||||||
[ -z "$BATCH" ] && break
|
|
||||||
REPOS="$REPOS $BATCH"
|
|
||||||
PAGE=$((PAGE + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
# Filter out excluded repos
|
|
||||||
FILTERED=""
|
|
||||||
for REPO in $REPOS; do
|
|
||||||
SKIP=false
|
|
||||||
for EX in $EXCLUDE; do
|
|
||||||
if [ "$REPO" = "$EX" ]; then
|
|
||||||
SKIP=true
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ "$SKIP" = "false" ]; then
|
|
||||||
FILTERED="$FILTERED $REPO"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
REPOS="$FILTERED"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "repos=$REPOS" >> "$GITHUB_OUTPUT"
|
|
||||||
COUNT=$(echo "$REPOS" | wc -w)
|
|
||||||
echo "📋 Target repos (${COUNT}): $REPOS"
|
|
||||||
|
|
||||||
- name: Apply protection rules
|
|
||||||
env:
|
|
||||||
GA_TOKEN: ${{ secrets.GA_TOKEN }}
|
|
||||||
DRY_RUN: ${{ inputs.dry_run || 'false' }}
|
|
||||||
run: |
|
|
||||||
API="${GITEA_URL}/api/v1"
|
|
||||||
REPOS="${{ steps.repos.outputs.repos }}"
|
|
||||||
|
|
||||||
SUCCESS=0
|
|
||||||
FAILED=0
|
|
||||||
SKIPPED=0
|
|
||||||
|
|
||||||
# ── Rule definitions ──────────────────────────────────────
|
|
||||||
# Only the CI bot (jmiller token) can push directly.
|
|
||||||
# All human contributors must use PRs.
|
|
||||||
# Force push disabled on all branches.
|
|
||||||
|
|
||||||
RULE_MAIN='{
|
|
||||||
"rule_name": "main",
|
|
||||||
"enable_push": true,
|
|
||||||
"enable_push_whitelist": true,
|
|
||||||
"push_whitelist_usernames": ["jmiller"],
|
|
||||||
"enable_force_push": false,
|
|
||||||
"enable_force_push_allowlist": false,
|
|
||||||
"force_push_allowlist_usernames": [],
|
|
||||||
"enable_merge_whitelist": false,
|
|
||||||
"required_approvals": 0,
|
|
||||||
"dismiss_stale_approvals": true,
|
|
||||||
"block_on_rejected_reviews": true,
|
|
||||||
"block_on_outdated_branch": false,
|
|
||||||
"priority": 1
|
|
||||||
}'
|
|
||||||
|
|
||||||
RULE_DEV='{
|
|
||||||
"rule_name": "dev",
|
|
||||||
"enable_push": true,
|
|
||||||
"enable_push_whitelist": true,
|
|
||||||
"push_whitelist_usernames": ["jmiller"],
|
|
||||||
"enable_force_push": false,
|
|
||||||
"enable_force_push_allowlist": false,
|
|
||||||
"force_push_allowlist_usernames": [],
|
|
||||||
"enable_merge_whitelist": false,
|
|
||||||
"required_approvals": 0,
|
|
||||||
"block_on_rejected_reviews": false,
|
|
||||||
"priority": 2
|
|
||||||
}'
|
|
||||||
|
|
||||||
RULE_RC='{
|
|
||||||
"rule_name": "rc",
|
|
||||||
"enable_push": true,
|
|
||||||
"enable_push_whitelist": true,
|
|
||||||
"push_whitelist_usernames": ["jmiller"],
|
|
||||||
"enable_force_push": false,
|
|
||||||
"enable_force_push_allowlist": false,
|
|
||||||
"force_push_allowlist_usernames": [],
|
|
||||||
"enable_merge_whitelist": false,
|
|
||||||
"required_approvals": 0,
|
|
||||||
"block_on_rejected_reviews": false,
|
|
||||||
"priority": 3
|
|
||||||
}'
|
|
||||||
|
|
||||||
RULE_BETA='{
|
|
||||||
"rule_name": "beta",
|
|
||||||
"enable_push": true,
|
|
||||||
"enable_push_whitelist": true,
|
|
||||||
"push_whitelist_usernames": ["jmiller"],
|
|
||||||
"enable_force_push": false,
|
|
||||||
"enable_force_push_allowlist": false,
|
|
||||||
"force_push_allowlist_usernames": [],
|
|
||||||
"enable_merge_whitelist": false,
|
|
||||||
"required_approvals": 0,
|
|
||||||
"block_on_rejected_reviews": false,
|
|
||||||
"priority": 4
|
|
||||||
}'
|
|
||||||
|
|
||||||
RULE_ALPHA='{
|
|
||||||
"rule_name": "alpha",
|
|
||||||
"enable_push": true,
|
|
||||||
"enable_push_whitelist": true,
|
|
||||||
"push_whitelist_usernames": ["jmiller"],
|
|
||||||
"enable_force_push": false,
|
|
||||||
"enable_force_push_allowlist": false,
|
|
||||||
"force_push_allowlist_usernames": [],
|
|
||||||
"enable_merge_whitelist": false,
|
|
||||||
"required_approvals": 0,
|
|
||||||
"block_on_rejected_reviews": false,
|
|
||||||
"priority": 5
|
|
||||||
}'
|
|
||||||
|
|
||||||
RULES=("$RULE_MAIN" "$RULE_DEV" "$RULE_RC" "$RULE_BETA" "$RULE_ALPHA")
|
|
||||||
RULE_NAMES=("main" "dev" "rc" "beta" "alpha")
|
|
||||||
|
|
||||||
# ── Apply rules to each repo ──────────────────────────────
|
|
||||||
for REPO in $REPOS; do
|
|
||||||
echo ""
|
|
||||||
echo "═══ ${REPO} ═══"
|
|
||||||
|
|
||||||
for i in "${!RULES[@]}"; do
|
|
||||||
RULE="${RULES[$i]}"
|
|
||||||
NAME="${RULE_NAMES[$i]}"
|
|
||||||
|
|
||||||
if [ "$DRY_RUN" = "true" ]; then
|
|
||||||
echo " [DRY RUN] Would apply rule: ${NAME}"
|
|
||||||
SKIPPED=$((SKIPPED + 1))
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Delete existing rule if present (idempotent recreate)
|
|
||||||
ENCODED_NAME=$(echo "$NAME" | sed 's|/|%2F|g')
|
|
||||||
curl -sS -o /dev/null -w "" \
|
|
||||||
-X DELETE \
|
|
||||||
-H "Authorization: token ${GA_TOKEN}" \
|
|
||||||
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections/${ENCODED_NAME}" 2>/dev/null || true
|
|
||||||
|
|
||||||
# Create rule
|
|
||||||
RESPONSE=$(curl -sS -w "\n%{http_code}" \
|
|
||||||
-X POST \
|
|
||||||
-H "Authorization: token ${GA_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "$RULE" \
|
|
||||||
"${API}/repos/${GITEA_ORG}/${REPO}/branch_protections")
|
|
||||||
|
|
||||||
HTTP=$(echo "$RESPONSE" | tail -1)
|
|
||||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
|
||||||
|
|
||||||
if [ "$HTTP" = "201" ]; then
|
|
||||||
echo " ✅ ${NAME}"
|
|
||||||
SUCCESS=$((SUCCESS + 1))
|
|
||||||
else
|
|
||||||
echo " ❌ ${NAME} (HTTP ${HTTP}): $(echo "$BODY" | jq -r '.message // .' 2>/dev/null | head -1)"
|
|
||||||
FAILED=$((FAILED + 1))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
# ── Summary ───────────────────────────────────────────────
|
|
||||||
echo ""
|
|
||||||
echo "════════════════════════════════════════"
|
|
||||||
echo " ✅ Success: ${SUCCESS}"
|
|
||||||
echo " ❌ Failed: ${FAILED}"
|
|
||||||
echo " ⏭️ Skipped: ${SKIPPED}"
|
|
||||||
echo "════════════════════════════════════════"
|
|
||||||
|
|
||||||
if [ "$FAILED" -gt 0 ]; then
|
|
||||||
echo "::warning::${FAILED} rule(s) failed to apply"
|
|
||||||
fi
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
# 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
|
|
||||||
- rc
|
|
||||||
- 'feature/**'
|
|
||||||
- 'patch/**'
|
|
||||||
|
|
||||||
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.MOKOGITEA_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.MOKOGITEA_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: |
|
|
||||||
php ${MOKO_CLI}/version_auto_bump.php \
|
|
||||||
--path . --branch "${GITHUB_REF_NAME}" \
|
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
|
||||||
--repo-url "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
|
||||||
@@ -1,341 +1,324 @@
|
|||||||
# 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-tech/moko-platform
|
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/moko-platform
|
||||||
# PATH: /templates/workflows/universal/auto-release.yml.template
|
# PATH: /templates/workflows/universal/auto-release.yml.template
|
||||||
# VERSION: 05.00.00
|
# VERSION: 05.00.00
|
||||||
# BRIEF: Universal build & release � detects platform from manifest.xml
|
# BRIEF: Universal build & release � detects platform from manifest.xml
|
||||||
#
|
#
|
||||||
# +========================================================================+
|
# +========================================================================+
|
||||||
# | UNIVERSAL BUILD & RELEASE PIPELINE |
|
# | UNIVERSAL BUILD & RELEASE PIPELINE |
|
||||||
# +========================================================================+
|
# +========================================================================+
|
||||||
# | |
|
# | |
|
||||||
# | Reads manifest.xml (joomla|dolibarr|generic) to branch logic. |
|
# | Reads manifest.xml (joomla|dolibarr|generic) to branch logic. |
|
||||||
# | |
|
# | |
|
||||||
# | Platform-specific: |
|
# | Platform-specific: |
|
||||||
# | joomla: XML manifest, type-prefixed packages |
|
# | joomla: XML manifest, type-prefixed packages |
|
||||||
# | dolibarr: mod*.class.php, update.txt, dev version reset |
|
# | dolibarr: mod*.class.php, update.txt, dev version reset |
|
||||||
# | generic: README-only, no update stream |
|
# | generic: README-only, no update stream |
|
||||||
# | |
|
# | |
|
||||||
# +========================================================================+
|
# +========================================================================+
|
||||||
|
|
||||||
name: "Universal: Build & Release"
|
name: "Universal: Build & Release"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, closed]
|
types: [opened, closed]
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
action:
|
action:
|
||||||
description: 'Action to perform'
|
description: 'Action to perform'
|
||||||
required: false
|
required: false
|
||||||
type: choice
|
type: choice
|
||||||
default: release
|
default: release
|
||||||
options:
|
options:
|
||||||
- release
|
- release
|
||||||
- promote-rc
|
- promote-rc
|
||||||
|
|
||||||
env:
|
env:
|
||||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
||||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
||||||
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
GITEA_ORG: ${{ vars.GITEA_ORG || github.repository_owner }}
|
||||||
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
GITEA_REPO: ${{ vars.GITEA_REPO || github.event.repository.name }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ── PR Opened → Rename branch to RC and build RC release ─────────────────────
|
# ── PR Opened → Rename branch to RC and build RC release ─────────────────────
|
||||||
promote-rc:
|
promote-rc:
|
||||||
name: Promote to RC
|
name: Promote to RC
|
||||||
runs-on: release
|
runs-on: release
|
||||||
if: >-
|
if: >-
|
||||||
(github.event.action == 'opened' && github.event.pull_request.merged != true) ||
|
(github.event.action == 'opened' && github.event.pull_request.merged != true) ||
|
||||||
(github.event_name == 'workflow_dispatch' && inputs.action == 'promote-rc')
|
(github.event_name == 'workflow_dispatch' && inputs.action == 'promote-rc')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Setup moko-platform tools
|
- name: Setup moko-platform tools
|
||||||
env:
|
env:
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||||
run: |
|
run: |
|
||||||
if [ -f /opt/moko-platform/cli/version_bump.php ] && [ -f /opt/moko-platform/vendor/autoload.php ]; then
|
if [ -f /opt/moko-platform/cli/version_bump.php ] && [ -f /opt/moko-platform/vendor/autoload.php ]; then
|
||||||
echo Using pre-installed /opt/moko-platform
|
echo Using pre-installed /opt/moko-platform
|
||||||
echo MOKO_CLI=/opt/moko-platform/cli >> $GITHUB_ENV
|
echo MOKO_CLI=/opt/moko-platform/cli >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo Falling back to fresh clone
|
echo Falling back to fresh clone
|
||||||
if ! command -v composer > /dev/null 2>&1; then
|
if ! command -v composer > /dev/null 2>&1; 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
|
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
|
fi
|
||||||
rm -rf /tmp/moko-platform-api
|
rm -rf /tmp/moko-platform-api
|
||||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git
|
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git
|
||||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/moko-platform-api
|
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/moko-platform-api
|
||||||
cd /tmp/moko-platform-api
|
cd /tmp/moko-platform-api
|
||||||
composer install --no-dev --no-interaction --quiet
|
composer install --no-dev --no-interaction --quiet
|
||||||
echo MOKO_CLI=/tmp/moko-platform-api/cli >> $GITHUB_ENV
|
echo MOKO_CLI=/tmp/moko-platform-api/cli >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Rename branch to rc
|
- name: Rename branch to rc
|
||||||
run: |
|
run: |
|
||||||
php ${MOKO_CLI}/branch_rename.php \
|
php ${MOKO_CLI}/branch_rename.php \
|
||||||
--from "${{ github.event.pull_request.head.ref || 'dev' }}" --to rc \
|
--from "${{ github.event.pull_request.head.ref || 'dev' }}" --to rc \
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||||
--api-base "${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}" \
|
--api-base "${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}" \
|
||||||
--pr "${{ github.event.pull_request.number }}"
|
--pr "${{ github.event.pull_request.number }}"
|
||||||
|
|
||||||
- name: Checkout rc and configure git
|
- name: Checkout rc and configure git
|
||||||
run: |
|
run: |
|
||||||
git fetch origin rc
|
git fetch origin rc
|
||||||
git checkout rc
|
git checkout rc
|
||||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
git config --local user.name "gitea-actions[bot]"
|
git config --local user.name "gitea-actions[bot]"
|
||||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
|
|
||||||
- name: Publish RC release
|
- name: Publish RC release
|
||||||
run: |
|
run: |
|
||||||
php ${MOKO_CLI}/release_publish.php \
|
php ${MOKO_CLI}/release_publish.php \
|
||||||
--path . --stability rc --bump minor --branch rc \
|
--path . --stability rc --bump minor --branch rc \
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}"
|
--token "${{ secrets.MOKOGITEA_TOKEN }}"
|
||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
echo "## Promoted to Release Candidate" >> $GITHUB_STEP_SUMMARY
|
echo "## Promoted to Release Candidate" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Branch renamed to rc, minor bump, RC release built" >> $GITHUB_STEP_SUMMARY
|
echo "Branch renamed to rc, minor bump, RC release built" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# ── Merged PR → Build & Release (or promote RC to stable) ────────────────────
|
# ── Merged PR → Build & Release (or promote RC to stable) ────────────────────
|
||||||
release:
|
release:
|
||||||
name: Build & Release Pipeline
|
name: Build & Release Pipeline
|
||||||
runs-on: release
|
runs-on: release
|
||||||
if: >-
|
if: >-
|
||||||
github.event.pull_request.merged == true ||
|
github.event.pull_request.merged == true ||
|
||||||
(github.event_name == 'workflow_dispatch' && inputs.action != 'promote-rc')
|
(github.event_name == 'workflow_dispatch' && inputs.action != 'promote-rc')
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Configure git for bot pushes
|
- name: Configure git for bot pushes
|
||||||
run: |
|
run: |
|
||||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
git config --local user.name "gitea-actions[bot]"
|
git config --local user.name "gitea-actions[bot]"
|
||||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
|
|
||||||
- name: Check for merge conflict markers
|
- name: Check for merge conflict markers
|
||||||
run: |
|
run: |
|
||||||
CONFLICTS=$(grep -rn '<<<<<<< \|>>>>>>> \|^=======$' --include='*.php' --include='*.xml' --include='*.css' --include='*.js' --include='*.json' --include='*.md' --include='*.yml' --include='*.yaml' --include='*.ini' --include='*.txt' . 2>/dev/null | grep -v '.git/' || true)
|
CONFLICTS=$(grep -rn '<<<<<<< \|>>>>>>> \|^=======$' --include='*.php' --include='*.xml' --include='*.css' --include='*.js' --include='*.json' --include='*.md' --include='*.yml' --include='*.yaml' --include='*.ini' --include='*.txt' . 2>/dev/null | grep -v '.git/' || true)
|
||||||
if [ -n "$CONFLICTS" ]; then
|
if [ -n "$CONFLICTS" ]; then
|
||||||
echo "::error::Merge conflict markers found — aborting release"
|
echo "::error::Merge conflict markers found — aborting release"
|
||||||
echo "## Release Blocked: Conflict Markers" >> $GITHUB_STEP_SUMMARY
|
echo "## Release Blocked: Conflict Markers" >> $GITHUB_STEP_SUMMARY
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
echo "$CONFLICTS" >> $GITHUB_STEP_SUMMARY
|
echo "$CONFLICTS" >> $GITHUB_STEP_SUMMARY
|
||||||
echo '```' >> $GITHUB_STEP_SUMMARY
|
echo '```' >> $GITHUB_STEP_SUMMARY
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "No conflict markers found"
|
echo "No conflict markers found"
|
||||||
|
|
||||||
- name: Setup moko-platform tools
|
- name: Setup moko-platform tools
|
||||||
env:
|
env:
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_MIRROR_TOKEN }}"}}'
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_MIRROR_TOKEN }}"}}'
|
||||||
run: |
|
run: |
|
||||||
if [ -f /opt/moko-platform/cli/version_bump.php ] && [ -f /opt/moko-platform/vendor/autoload.php ]; then
|
if [ -f /opt/moko-platform/cli/version_bump.php ] && [ -f /opt/moko-platform/vendor/autoload.php ]; then
|
||||||
echo Using pre-installed /opt/moko-platform
|
echo Using pre-installed /opt/moko-platform
|
||||||
echo MOKO_CLI=/opt/moko-platform/cli >> $GITHUB_ENV
|
echo MOKO_CLI=/opt/moko-platform/cli >> $GITHUB_ENV
|
||||||
else
|
else
|
||||||
echo Falling back to fresh clone
|
echo Falling back to fresh clone
|
||||||
if ! command -v composer > /dev/null 2>&1; then
|
if ! command -v composer > /dev/null 2>&1; 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
|
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
|
fi
|
||||||
rm -rf /tmp/moko-platform-api
|
rm -rf /tmp/moko-platform-api
|
||||||
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git
|
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git
|
||||||
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/moko-platform-api
|
git clone --depth 1 --branch main --quiet $CLONE_URL /tmp/moko-platform-api
|
||||||
cd /tmp/moko-platform-api
|
cd /tmp/moko-platform-api
|
||||||
composer install --no-dev --no-interaction --quiet
|
composer install --no-dev --no-interaction --quiet
|
||||||
echo MOKO_CLI=/tmp/moko-platform-api/cli >> $GITHUB_ENV
|
echo MOKO_CLI=/tmp/moko-platform-api/cli >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: "Determine version bump level"
|
- name: "Publish stable release"
|
||||||
id: bump
|
run: |
|
||||||
run: |
|
php ${MOKO_CLI}/release_publish.php \
|
||||||
# Fix/patch branches: version was already bumped by pre-release, just strip suffix
|
--path . --stability stable --bump minor --branch main \
|
||||||
# Feature/dev branches: bump minor for the new stable release
|
--token "${{ secrets.MOKOGITEA_TOKEN }}"
|
||||||
HEAD_REF="${{ github.event.pull_request.head.ref || 'dev' }}"
|
|
||||||
case "$HEAD_REF" in
|
- name: Update release notes from CHANGELOG.md
|
||||||
fix/*|patch/*|hotfix/*|bugfix/*) BUMP="none" ;;
|
run: |
|
||||||
*) BUMP="minor" ;;
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
esac
|
|
||||||
echo "level=${BUMP}" >> "$GITHUB_OUTPUT"
|
# Extract [Unreleased] section from changelog
|
||||||
echo "Bump level: ${BUMP} (from branch: ${HEAD_REF})"
|
if [ -f "CHANGELOG.md" ]; then
|
||||||
|
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||||
- name: "Publish stable release"
|
[ -z "$NOTES" ] && NOTES="Stable release"
|
||||||
run: |
|
else
|
||||||
BUMP_FLAG=""
|
NOTES="Stable release"
|
||||||
if [ "${{ steps.bump.outputs.level }}" != "none" ]; then
|
fi
|
||||||
BUMP_FLAG="--bump ${{ steps.bump.outputs.level }}"
|
|
||||||
fi
|
# Update release body via API
|
||||||
php ${MOKO_CLI}/release_publish.php \
|
RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||||
--path . --stability stable ${BUMP_FLAG} --branch main \
|
"${API_BASE}/releases/tags/stable" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}"
|
|
||||||
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
- name: Update release notes from CHANGELOG.md
|
python3 -c "
|
||||||
run: |
|
import json, urllib.request
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
body = open('/dev/stdin').read()
|
||||||
|
payload = json.dumps({'body': body}).encode()
|
||||||
# Extract [Unreleased] section from changelog
|
req = urllib.request.Request(
|
||||||
if [ -f "CHANGELOG.md" ]; then
|
'${API_BASE}/releases/${RELEASE_ID}',
|
||||||
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
data=payload, method='PATCH',
|
||||||
[ -z "$NOTES" ] && NOTES="Stable release"
|
headers={
|
||||||
else
|
'Authorization': 'token ${{ secrets.MOKOGITEA_TOKEN }}',
|
||||||
NOTES="Stable release"
|
'Content-Type': 'application/json'
|
||||||
fi
|
})
|
||||||
|
urllib.request.urlopen(req)
|
||||||
# Update release body via API
|
" <<< "$NOTES"
|
||||||
RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
echo "Release notes updated from CHANGELOG.md"
|
||||||
"${API_BASE}/releases/tags/stable" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
fi
|
||||||
|
|
||||||
if [ -n "$RELEASE_ID" ]; then
|
# -- STEP 9: Mirror to GitHub (stable only) --------------------------------
|
||||||
python3 -c "
|
- name: "Step 9: Mirror release to GitHub"
|
||||||
import json, urllib.request
|
if: >-
|
||||||
body = open('/dev/stdin').read()
|
steps.version.outputs.skip != 'true' &&
|
||||||
payload = json.dumps({'body': body}).encode()
|
secrets.GH_MIRROR_TOKEN != ''
|
||||||
req = urllib.request.Request(
|
continue-on-error: true
|
||||||
'${API_BASE}/releases/${RELEASE_ID}',
|
run: |
|
||||||
data=payload, method='PATCH',
|
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||||
headers={
|
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
||||||
'Authorization': 'token ${{ secrets.MOKOGITEA_TOKEN }}',
|
GH_REPO="${{ vars.GH_MIRROR_REPO || github.repository }}"
|
||||||
'Content-Type': 'application/json'
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
})
|
php ${MOKO_CLI}/release_mirror.php \
|
||||||
urllib.request.urlopen(req)
|
--version "$VERSION" --tag "$RELEASE_TAG" \
|
||||||
" <<< "$NOTES"
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
echo "Release notes updated from CHANGELOG.md"
|
--gh-token "${{ secrets.GH_MIRROR_TOKEN }}" --gh-repo "$GH_REPO" \
|
||||||
fi
|
--branch main 2>&1 || true
|
||||||
|
echo "GitHub mirror updated" >> $GITHUB_STEP_SUMMARY
|
||||||
# -- STEP 9: Mirror to GitHub (stable only) --------------------------------
|
|
||||||
- name: "Step 9: Mirror release to GitHub"
|
# -- STEP 10: Sync main branch to GitHub mirror ----------------------------
|
||||||
if: >-
|
- name: "Step 10: Push main to GitHub mirror"
|
||||||
steps.version.outputs.skip != 'true' &&
|
if: >-
|
||||||
secrets.GH_MIRROR_TOKEN != ''
|
steps.version.outputs.skip != 'true' &&
|
||||||
continue-on-error: true
|
secrets.GH_MIRROR_TOKEN != ''
|
||||||
run: |
|
continue-on-error: true
|
||||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
run: |
|
||||||
RELEASE_TAG="${{ steps.version.outputs.release_tag }}"
|
GH_REPO="${{ vars.GH_MIRROR_REPO || github.repository }}"
|
||||||
GH_REPO="${{ vars.GH_MIRROR_REPO || github.repository }}"
|
GH_ORG=$(echo "$GH_REPO" | cut -d/ -f1)
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
GH_NAME=$(echo "$GH_REPO" | cut -d/ -f2)
|
||||||
php ${MOKO_CLI}/release_mirror.php \
|
git remote add github "https://x-access-token:${{ secrets.GH_MIRROR_TOKEN }}@github.com/${GH_ORG}/${GH_NAME}.git" 2>/dev/null || \
|
||||||
--version "$VERSION" --tag "$RELEASE_TAG" \
|
git remote set-url github "https://x-access-token:${{ secrets.GH_MIRROR_TOKEN }}@github.com/${GH_ORG}/${GH_NAME}.git"
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
git fetch origin main --depth=1
|
||||||
--gh-token "${{ secrets.GH_MIRROR_TOKEN }}" --gh-repo "$GH_REPO" \
|
git push github origin/main:refs/heads/main --force 2>/dev/null \
|
||||||
--branch main 2>&1 || true
|
&& echo "main branch pushed to GitHub mirror" \
|
||||||
echo "GitHub mirror updated" >> $GITHUB_STEP_SUMMARY
|
|| echo "WARNING: GitHub mirror push failed"
|
||||||
|
|
||||||
# -- STEP 10: Sync main branch to GitHub mirror ----------------------------
|
- name: "Step 11: Delete rc branch and recreate dev from main"
|
||||||
- name: "Step 10: Push main to GitHub mirror"
|
if: steps.version.outputs.skip != 'true'
|
||||||
if: >-
|
continue-on-error: true
|
||||||
steps.version.outputs.skip != 'true' &&
|
run: |
|
||||||
secrets.GH_MIRROR_TOKEN != ''
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
continue-on-error: true
|
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||||
run: |
|
|
||||||
GH_REPO="${{ vars.GH_MIRROR_REPO || github.repository }}"
|
# Delete rc branch (ephemeral — created by promote-rc)
|
||||||
GH_ORG=$(echo "$GH_REPO" | cut -d/ -f1)
|
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
||||||
GH_NAME=$(echo "$GH_REPO" | cut -d/ -f2)
|
"${API_BASE}/branches/rc" 2>/dev/null \
|
||||||
git remote add github "https://x-access-token:${{ secrets.GH_MIRROR_TOKEN }}@github.com/${GH_ORG}/${GH_NAME}.git" 2>/dev/null || \
|
&& echo "Deleted rc branch" || echo "rc branch not found"
|
||||||
git remote set-url github "https://x-access-token:${{ secrets.GH_MIRROR_TOKEN }}@github.com/${GH_ORG}/${GH_NAME}.git"
|
|
||||||
git fetch origin main --depth=1
|
# Delete dev branch
|
||||||
git push github origin/main:refs/heads/main --force 2>/dev/null \
|
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
||||||
&& echo "main branch pushed to GitHub mirror" \
|
"${API_BASE}/branches/dev" 2>/dev/null && echo "Deleted dev branch"
|
||||||
|| echo "WARNING: GitHub mirror push failed"
|
|
||||||
|
# Recreate dev from main (now includes version bump + changelog promotion)
|
||||||
- name: "Step 11: Delete rc branch and recreate dev from main"
|
curl -sf -X POST -H "Authorization: token ${TOKEN}" \
|
||||||
if: steps.version.outputs.skip != 'true'
|
-H "Content-Type: application/json" \
|
||||||
continue-on-error: true
|
"${API_BASE}/branches" \
|
||||||
run: |
|
-d '{"new_branch_name":"dev","old_branch_name":"main"}' 2>/dev/null && echo "Recreated dev from main"
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
echo "Pre-release branches cleaned, dev reset from main" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
# Delete rc branch (ephemeral — created by promote-rc)
|
- name: "Step 12: Create version branch from main"
|
||||||
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
if: steps.version.outputs.skip != 'true'
|
||||||
"${API_BASE}/branches/rc" 2>/dev/null \
|
continue-on-error: true
|
||||||
&& echo "Deleted rc branch" || echo "rc branch not found"
|
run: |
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
# Delete dev branch
|
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||||
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" \
|
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||||
"${API_BASE}/branches/dev" 2>/dev/null && echo "Deleted dev branch"
|
BRANCH_NAME="version/${VERSION}"
|
||||||
|
MAIN_SHA=$(git rev-parse HEAD)
|
||||||
# Recreate dev from main (now includes version bump + changelog promotion)
|
|
||||||
curl -sf -X POST -H "Authorization: token ${TOKEN}" \
|
# Delete old version branch if it exists (same version re-release)
|
||||||
-H "Content-Type: application/json" \
|
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" "${API_BASE}/branches/${BRANCH_NAME}" 2>/dev/null && echo "Deleted old ${BRANCH_NAME}"
|
||||||
"${API_BASE}/branches" \
|
|
||||||
-d '{"new_branch_name":"dev","old_branch_name":"main"}' 2>/dev/null && echo "Recreated dev from main"
|
# Create version/XX.YY.ZZ from main
|
||||||
|
curl -sf -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" "${API_BASE}/branches" -d "{\"new_branch_name\":\"${BRANCH_NAME}\",\"old_branch_name\":\"main\"}" 2>/dev/null && echo "Created ${BRANCH_NAME} from main (${MAIN_SHA})" || echo "WARNING: ${BRANCH_NAME} creation failed"
|
||||||
echo "Pre-release branches cleaned, dev reset from main" >> $GITHUB_STEP_SUMMARY
|
|
||||||
|
echo "Version branch created: ${BRANCH_NAME} (${MAIN_SHA})" >> $GITHUB_STEP_SUMMARY
|
||||||
- name: "Step 12: Create version branch from main"
|
|
||||||
if: steps.version.outputs.skip != 'true'
|
|
||||||
continue-on-error: true
|
|
||||||
run: |
|
# -- Dolibarr post-release: Reset dev version -----------------------------
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
- name: "Post-release: Reset dev version"
|
||||||
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
if: steps.version.outputs.skip != 'true'
|
||||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
continue-on-error: true
|
||||||
BRANCH_NAME="version/${VERSION}"
|
run: |
|
||||||
MAIN_SHA=$(git rev-parse HEAD)
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
php ${MOKO_CLI}/version_reset_dev.php \
|
||||||
# Delete old version branch if it exists (same version re-release)
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "${API_BASE}" \
|
||||||
curl -sf -X DELETE -H "Authorization: token ${TOKEN}" "${API_BASE}/branches/${BRANCH_NAME}" 2>/dev/null && echo "Deleted old ${BRANCH_NAME}"
|
--branch dev --path . 2>&1 || true
|
||||||
|
|
||||||
# Create version/XX.YY.ZZ from main
|
# -- Summary --------------------------------------------------------------
|
||||||
curl -sf -X POST -H "Authorization: token ${TOKEN}" -H "Content-Type: application/json" "${API_BASE}/branches" -d "{\"new_branch_name\":\"${BRANCH_NAME}\",\"old_branch_name\":\"main\"}" 2>/dev/null && echo "Created ${BRANCH_NAME} from main (${MAIN_SHA})" || echo "WARNING: ${BRANCH_NAME} creation failed"
|
- name: Pipeline Summary
|
||||||
|
if: always()
|
||||||
echo "Version branch created: ${BRANCH_NAME} (${MAIN_SHA})" >> $GITHUB_STEP_SUMMARY
|
run: |
|
||||||
|
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
||||||
|
PLATFORM="${{ steps.platform.outputs.platform }}"
|
||||||
|
if [ "${{ steps.version.outputs.skip }}" = "true" ]; then
|
||||||
# -- Dolibarr post-release: Reset dev version -----------------------------
|
echo "## Release Skipped" >> $GITHUB_STEP_SUMMARY
|
||||||
- name: "Post-release: Reset dev version"
|
echo "No VERSION in README.md" >> $GITHUB_STEP_SUMMARY
|
||||||
if: steps.version.outputs.skip != 'true'
|
elif [ "${{ steps.check.outputs.already_released }}" = "true" ]; then
|
||||||
continue-on-error: true
|
echo "## Already Released — ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
||||||
run: |
|
else
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
php ${MOKO_CLI}/version_reset_dev.php \
|
echo "## Build & Release Complete (${PLATFORM})" >> $GITHUB_STEP_SUMMARY
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "${API_BASE}" \
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
--branch dev --path . 2>&1 || true
|
echo "| Step | Result |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
|
||||||
# -- Summary --------------------------------------------------------------
|
echo "| Platform | \`${PLATFORM}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
- name: Pipeline Summary
|
echo "| Version | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
if: always()
|
echo "| Branch | \`${{ steps.version.outputs.branch }}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
run: |
|
echo "| Tag | \`${{ steps.version.outputs.tag }}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}"
|
echo "| Release | [View](${GITEA_URL}/${GITEA_ORG}/${GITEA_REPO}/releases/tag/${{ steps.version.outputs.tag }}) |" >> $GITHUB_STEP_SUMMARY
|
||||||
PLATFORM="${{ steps.platform.outputs.platform }}"
|
fi
|
||||||
if [ "${{ steps.version.outputs.skip }}" = "true" ]; then
|
|
||||||
echo "## Release Skipped" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "No VERSION in README.md" >> $GITHUB_STEP_SUMMARY
|
|
||||||
elif [ "${{ steps.check.outputs.already_released }}" = "true" ]; then
|
|
||||||
echo "## Already Released — ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
else
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "## Build & Release Complete (${PLATFORM})" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Step | Result |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Platform | \`${PLATFORM}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Version | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Branch | \`${{ steps.version.outputs.branch }}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Tag | \`${{ steps.version.outputs.tag }}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "| Release | [View](${GITEA_URL}/${GITEA_ORG}/${GITEA_REPO}/releases/tag/${{ steps.version.outputs.tag }}) |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
# 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: /.mokogitea/workflows/branch-cleanup.yml
|
|
||||||
# VERSION: 01.00.00
|
|
||||||
# BRIEF: Delete feature branches after PR merge
|
|
||||||
|
|
||||||
name: "Branch Cleanup"
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [closed]
|
|
||||||
|
|
||||||
env:
|
|
||||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
cleanup:
|
|
||||||
name: Delete merged branch
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: >-
|
|
||||||
github.event.pull_request.merged == true &&
|
|
||||||
github.event.pull_request.head.ref != 'dev' &&
|
|
||||||
github.event.pull_request.head.ref != 'main'
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Delete source branch
|
|
||||||
run: |
|
|
||||||
BRANCH="${{ github.event.pull_request.head.ref }}"
|
|
||||||
API="${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}/api/v1/repos/${{ github.repository }}/branches"
|
|
||||||
ENCODED=$(php -r "echo rawurlencode('${BRANCH}');")
|
|
||||||
|
|
||||||
STATUS=$(curl -sf -o /dev/null -w "%{http_code}" -X DELETE \
|
|
||||||
-H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
|
||||||
"${API}/${ENCODED}" 2>/dev/null || true)
|
|
||||||
|
|
||||||
if [ "$STATUS" = "204" ]; then
|
|
||||||
echo "Deleted branch: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
elif [ "$STATUS" = "404" ]; then
|
|
||||||
echo "Branch already deleted: ${BRANCH}" >> $GITHUB_STEP_SUMMARY
|
|
||||||
else
|
|
||||||
echo "::warning::Failed to delete branch ${BRANCH} (HTTP ${STATUS})"
|
|
||||||
fi
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
# DISABLED — auto-release Step 11 recreates dev from main after every release.
|
|
||||||
# Cascade-dev is redundant and causes version conflicts when both main and dev
|
|
||||||
# have different version numbers in templateDetails.xml / manifest.xml.
|
|
||||||
name: "Cascade Main → Dev (DISABLED)"
|
|
||||||
on: workflow_dispatch
|
|
||||||
jobs:
|
|
||||||
noop:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- run: echo "Cascade disabled — auto-release handles dev recreation"
|
|
||||||
@@ -1,204 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: MokoStandards.CI
|
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic
|
|
||||||
# PATH: /.gitea/workflows/ci-generic.yml
|
|
||||||
# VERSION: 01.00.00
|
|
||||||
# BRIEF: CI pipeline — lint, validate, and test for generic projects (PHP + Node.js)
|
|
||||||
|
|
||||||
name: "Generic: Project CI"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- dev
|
|
||||||
- dev/**
|
|
||||||
- rc/**
|
|
||||||
- version/**
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- dev
|
|
||||||
- dev/**
|
|
||||||
- rc/**
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
env:
|
|
||||||
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
# ── Lint & Validate ───────────────────────────────────────────────────
|
|
||||||
lint:
|
|
||||||
name: Lint & Validate
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Detect toolchain
|
|
||||||
id: detect
|
|
||||||
run: |
|
|
||||||
HAS_PHP=false
|
|
||||||
HAS_NODE=false
|
|
||||||
[ -f "composer.json" ] && HAS_PHP=true
|
|
||||||
[ -f "package.json" ] && HAS_NODE=true
|
|
||||||
echo "has_php=$HAS_PHP" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "has_node=$HAS_NODE" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "Toolchain: PHP=$HAS_PHP Node=$HAS_NODE"
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
if: steps.detect.outputs.has_php == 'true'
|
|
||||||
run: |
|
|
||||||
if ! command -v php &> /dev/null; then
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -y -qq php-cli php-mbstring php-xml >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
php -v
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
if: steps.detect.outputs.has_node == 'true'
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
|
|
||||||
- name: Install PHP dependencies
|
|
||||||
if: steps.detect.outputs.has_php == 'true'
|
|
||||||
run: |
|
|
||||||
if [ -f "composer.json" ]; then
|
|
||||||
composer install --no-interaction --prefer-dist --quiet 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
if: steps.detect.outputs.has_node == 'true'
|
|
||||||
run: |
|
|
||||||
if [ -f "package.json" ]; then
|
|
||||||
npm ci --quiet 2>/dev/null || npm install --quiet 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: PHP syntax check
|
|
||||||
if: steps.detect.outputs.has_php == 'true'
|
|
||||||
run: |
|
|
||||||
ERRORS=0
|
|
||||||
while IFS= read -r -d '' file; do
|
|
||||||
if ! php -l "$file" 2>&1 | grep -q "No syntax errors"; then
|
|
||||||
echo "::error file=${file}::PHP syntax error"
|
|
||||||
ERRORS=$((ERRORS + 1))
|
|
||||||
fi
|
|
||||||
done < <(find . -name "*.php" -not -path "./.git/*" -not -path "./vendor/*" -not -path "./node_modules/*" -print0)
|
|
||||||
|
|
||||||
echo "## PHP Lint" >> $GITHUB_STEP_SUMMARY
|
|
||||||
if [ "$ERRORS" -eq 0 ]; then
|
|
||||||
echo "All PHP files passed syntax check." >> $GITHUB_STEP_SUMMARY
|
|
||||||
else
|
|
||||||
echo "${ERRORS} file(s) with syntax errors." >> $GITHUB_STEP_SUMMARY
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: TypeScript/JavaScript lint
|
|
||||||
if: steps.detect.outputs.has_node == 'true'
|
|
||||||
run: |
|
|
||||||
if [ -f "node_modules/.bin/eslint" ]; then
|
|
||||||
npx eslint src/ --quiet 2>&1 || { echo "::error::ESLint errors found"; exit 1; }
|
|
||||||
echo "## ESLint" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "All files passed ESLint." >> $GITHUB_STEP_SUMMARY
|
|
||||||
elif [ -f ".eslintrc.json" ] || [ -f ".eslintrc.js" ] || [ -f "eslint.config.js" ]; then
|
|
||||||
echo "::warning::ESLint config found but eslint not installed"
|
|
||||||
else
|
|
||||||
echo "No ESLint configured — skipping"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: TypeScript compile check
|
|
||||||
if: steps.detect.outputs.has_node == 'true'
|
|
||||||
run: |
|
|
||||||
if [ -f "tsconfig.json" ] && [ -f "node_modules/.bin/tsc" ]; then
|
|
||||||
npx tsc --noEmit 2>&1 || { echo "::error::TypeScript compilation errors"; exit 1; }
|
|
||||||
echo "## TypeScript" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "TypeScript compilation passed." >> $GITHUB_STEP_SUMMARY
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: PHPStan static analysis
|
|
||||||
if: steps.detect.outputs.has_php == 'true'
|
|
||||||
run: |
|
|
||||||
if [ -f "phpstan.neon" ] && [ -f "vendor/bin/phpstan" ]; then
|
|
||||||
vendor/bin/phpstan analyse --no-progress 2>&1 || { echo "::warning::PHPStan found issues"; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Tests ─────────────────────────────────────────────────────────────
|
|
||||||
test:
|
|
||||||
name: Tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: lint
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Detect toolchain
|
|
||||||
id: detect
|
|
||||||
run: |
|
|
||||||
HAS_PHP=false
|
|
||||||
HAS_NODE=false
|
|
||||||
[ -f "composer.json" ] && HAS_PHP=true
|
|
||||||
[ -f "package.json" ] && HAS_NODE=true
|
|
||||||
echo "has_php=$HAS_PHP" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "has_node=$HAS_NODE" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Setup PHP
|
|
||||||
if: steps.detect.outputs.has_php == 'true'
|
|
||||||
run: |
|
|
||||||
if ! command -v php &> /dev/null; then
|
|
||||||
sudo apt-get update -qq
|
|
||||||
sudo apt-get install -y -qq php-cli php-mbstring php-xml >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
if: steps.detect.outputs.has_node == 'true'
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
[ -f "composer.json" ] && composer install --no-interaction --prefer-dist --quiet 2>/dev/null || true
|
|
||||||
[ -f "package.json" ] && { npm ci --quiet 2>/dev/null || npm install --quiet 2>/dev/null || true; }
|
|
||||||
|
|
||||||
- name: Run PHP tests
|
|
||||||
if: steps.detect.outputs.has_php == 'true'
|
|
||||||
run: |
|
|
||||||
if [ -f "vendor/bin/phpunit" ]; then
|
|
||||||
vendor/bin/phpunit --testdox 2>&1
|
|
||||||
echo "## PHPUnit" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "Tests passed." >> $GITHUB_STEP_SUMMARY
|
|
||||||
elif [ -f "phpunit.xml" ] || [ -f "phpunit.xml.dist" ]; then
|
|
||||||
echo "::warning::PHPUnit config found but phpunit not installed"
|
|
||||||
else
|
|
||||||
echo "No PHPUnit configured — skipping"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run Node.js tests
|
|
||||||
if: steps.detect.outputs.has_node == 'true'
|
|
||||||
run: |
|
|
||||||
if jq -e '.scripts.test' package.json > /dev/null 2>&1; then
|
|
||||||
npm test 2>&1
|
|
||||||
echo "## Node.js Tests" >> $GITHUB_STEP_SUMMARY
|
|
||||||
echo "Tests passed." >> $GITHUB_STEP_SUMMARY
|
|
||||||
else
|
|
||||||
echo "No test script in package.json — skipping"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Build check
|
|
||||||
run: |
|
|
||||||
if [ -f "Makefile" ]; then
|
|
||||||
make build 2>&1 || echo "::warning::Build failed or not configured"
|
|
||||||
elif [ -f "package.json" ] && jq -e '.scripts.build' package.json > /dev/null 2>&1; then
|
|
||||||
npm run build 2>&1 || echo "::warning::Build failed"
|
|
||||||
fi
|
|
||||||
@@ -4,8 +4,8 @@
|
|||||||
#
|
#
|
||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: MokoStandards.Maintenance
|
# INGROUP: moko-platform.Maintenance
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
# PATH: /.gitea/workflows/cleanup.yml
|
# PATH: /.gitea/workflows/cleanup.yml
|
||||||
# VERSION: 01.00.00
|
# VERSION: 01.00.00
|
||||||
# BRIEF: Scheduled cleanup — delete merged branches and old workflow runs
|
# BRIEF: Scheduled cleanup — delete merged branches and old workflow runs
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#
|
#
|
||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: MokoStandards.Deploy
|
# INGROUP: moko-platform.Deploy
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards-API
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
# PATH: /templates/workflows/joomla/deploy-manual.yml.template
|
# PATH: /templates/workflows/joomla/deploy-manual.yml.template
|
||||||
# VERSION: 04.07.00
|
# VERSION: 04.07.00
|
||||||
# BRIEF: Manual SFTP deploy to dev server for Joomla repos
|
# BRIEF: Manual SFTP deploy to dev server for Joomla repos
|
||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
php -v && composer --version
|
php -v && composer --version
|
||||||
|
|
||||||
- name: Setup MokoStandards tools
|
- name: Setup moko-platform tools
|
||||||
env:
|
env:
|
||||||
GA_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
GA_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
MOKO_CLONE_TOKEN: ${{ secrets.GA_TOKEN || secrets.GA_TOKEN || github.token }}
|
||||||
@@ -48,10 +48,10 @@ jobs:
|
|||||||
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GA_TOKEN || github.token }}"}}'
|
||||||
run: |
|
run: |
|
||||||
git clone --depth 1 --branch main --quiet \
|
git clone --depth 1 --branch main --quiet \
|
||||||
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/MokoStandards-API.git" \
|
"https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git" \
|
||||||
/tmp/mokostandards-api 2>/dev/null || true
|
/tmp/moko-platform-api 2>/dev/null || true
|
||||||
if [ -d "/tmp/mokostandards-api" ] && [ -f "/tmp/mokostandards-api/composer.json" ]; then
|
if [ -d "/tmp/moko-platform-api" ] && [ -f "/tmp/moko-platform-api/composer.json" ]; then
|
||||||
cd /tmp/mokostandards-api && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
cd /tmp/moko-platform-api && composer install --no-dev --no-interaction --quiet 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check FTP configuration
|
- name: Check FTP configuration
|
||||||
@@ -101,15 +101,28 @@ jobs:
|
|||||||
DEPLOY_ARGS=(--path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json)
|
DEPLOY_ARGS=(--path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json)
|
||||||
[ "${{ inputs.clear_remote }}" = "true" ] && DEPLOY_ARGS+=(--clear-remote)
|
[ "${{ inputs.clear_remote }}" = "true" ] && DEPLOY_ARGS+=(--clear-remote)
|
||||||
|
|
||||||
PLATFORM=$(php /tmp/mokostandards-api/cli/platform_detect.php --path . 2>/dev/null || true)
|
PLATFORM=$(php /tmp/moko-platform-api/cli/platform_detect.php --path . 2>/dev/null || true)
|
||||||
if [ "$PLATFORM" = "waas-component" ] && [ -f "/tmp/mokostandards-api/deploy/deploy-joomla.php" ]; then
|
if [ "$PLATFORM" = "waas-component" ] && [ -f "/tmp/moko-platform-api/deploy/deploy-joomla.php" ]; then
|
||||||
php /tmp/mokostandards-api/deploy/deploy-joomla.php "${DEPLOY_ARGS[@]}"
|
php /tmp/moko-platform-api/deploy/deploy-joomla.php "${DEPLOY_ARGS[@]}"
|
||||||
else
|
else
|
||||||
php /tmp/mokostandards-api/deploy/deploy-sftp.php "${DEPLOY_ARGS[@]}"
|
php /tmp/moko-platform-api/deploy/deploy-sftp.php "${DEPLOY_ARGS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
rm -f /tmp/deploy_key /tmp/sftp-config.json
|
||||||
|
|
||||||
|
|
||||||
|
- name: Post-deploy health check
|
||||||
|
if: success() && steps.check.outputs.skip != 'true'
|
||||||
|
run: |
|
||||||
|
if [ -f "deploy/health-check.php" ]; then
|
||||||
|
SITE_URL="${{ vars.DEV_SITE_URL }}"
|
||||||
|
if [ -n "$SITE_URL" ]; then
|
||||||
|
php deploy/health-check.php --url "$SITE_URL" --checks http --timeout 30 || echo "::warning::Health check failed after deploy"
|
||||||
|
else
|
||||||
|
echo "DEV_SITE_URL not configured, skipping health check"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
if: always()
|
if: always()
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#
|
#
|
||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: MokoStandards.Security
|
# INGROUP: moko-platform.Security
|
||||||
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/MokoStandards-API
|
# REPO: https://git.mokoconsulting.tech/mokoconsulting-tech/moko-platform
|
||||||
# PATH: /templates/workflows/gitleaks.yml.template
|
# PATH: /templates/workflows/gitleaks.yml.template
|
||||||
# VERSION: 01.00.00
|
# VERSION: 01.00.00
|
||||||
# BRIEF: Secret scanning — detect leaked credentials, API keys, and tokens
|
# BRIEF: Secret scanning — detect leaked credentials, API keys, and tokens
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: moko-platform.Automation
|
|
||||||
# VERSION: 01.00.00
|
|
||||||
# BRIEF: Auto-create feature branch when an issue is opened
|
|
||||||
|
|
||||||
name: "Universal: Issue Branch"
|
|
||||||
|
|
||||||
on:
|
|
||||||
issues:
|
|
||||||
types: [opened]
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
issues: write
|
|
||||||
|
|
||||||
env:
|
|
||||||
GITEA_URL: ${{ vars.GITEA_URL || 'https://git.mokoconsulting.tech' }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
create-branch:
|
|
||||||
name: Create feature branch
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Create branch and comment
|
|
||||||
run: |
|
|
||||||
TOKEN="${{ secrets.GA_TOKEN }}"
|
|
||||||
API="${GITEA_URL}/api/v1/repos/${{ github.repository }}"
|
|
||||||
ISSUE_NUM="${{ github.event.issue.number }}"
|
|
||||||
ISSUE_TITLE="${{ github.event.issue.title }}"
|
|
||||||
|
|
||||||
# Build slug from title: lowercase, replace non-alnum with dash, trim
|
|
||||||
SLUG=$(echo "${ISSUE_TITLE}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//' | cut -c1-40)
|
|
||||||
BRANCH="feature/${ISSUE_NUM}-${SLUG}"
|
|
||||||
|
|
||||||
# Check dev branch exists
|
|
||||||
DEV_EXISTS=$(curl -sf -o /dev/null -w '%{http_code}' \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
"${API}/branches/dev" 2>/dev/null || echo "000")
|
|
||||||
|
|
||||||
if [ "${DEV_EXISTS}" != "200" ]; then
|
|
||||||
echo "No dev branch -- skipping"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create branch from dev
|
|
||||||
HTTP=$(curl -sf -o /dev/null -w '%{http_code}' -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${API}/branches" \
|
|
||||||
-d "{\"new_branch_name\":\"${BRANCH}\",\"old_branch_name\":\"dev\"}" 2>/dev/null || echo "000")
|
|
||||||
|
|
||||||
if [ "${HTTP}" = "201" ]; then
|
|
||||||
echo "Created branch: ${BRANCH}"
|
|
||||||
|
|
||||||
# Comment on issue with branch link
|
|
||||||
REPO_URL="${GITEA_URL}/${{ github.repository }}"
|
|
||||||
BODY="Branch created: [\`${BRANCH}\`](${REPO_URL}/src/branch/${BRANCH})\n\n\`\`\`bash\ngit fetch origin\ngit checkout ${BRANCH}\n\`\`\`"
|
|
||||||
|
|
||||||
curl -sf -X POST \
|
|
||||||
-H "Authorization: token ${TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
"${API}/issues/${ISSUE_NUM}/comments" \
|
|
||||||
-d "{\"body\":\"${BODY}\"}" > /dev/null 2>&1
|
|
||||||
|
|
||||||
echo "Commented on issue #${ISSUE_NUM}"
|
|
||||||
else
|
|
||||||
echo "Failed to create branch (HTTP ${HTTP}) -- may already exist"
|
|
||||||
fi
|
|
||||||
@@ -88,17 +88,15 @@ jobs:
|
|||||||
|
|
||||||
# ── Version ──────────────────────────────────────────────────────
|
# ── Version ──────────────────────────────────────────────────────
|
||||||
- name: Setup MokoStandards tools
|
- name: Setup MokoStandards tools
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
|
||||||
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || github.token }}"}}'
|
||||||
run: |
|
run: |
|
||||||
if [ -d /opt/mokoplatform/api/cli ] && [ -f /opt/mokoplatform/vendor/autoload.php ]; then
|
git clone --depth 1 --branch version/04 --quiet \
|
||||||
ln -sf /opt/mokoplatform /tmp/mokostandards
|
"https://x-access-token:${GH_TOKEN}@github.com/mokoconsulting-tech/MokoStandards.git" \
|
||||||
echo "Using pre-installed /opt/mokoplatform"
|
/tmp/mokostandards
|
||||||
elif [ -d /opt/moko-platform/api/cli ]; then
|
cd /tmp/mokostandards
|
||||||
ln -sf /opt/moko-platform /tmp/mokostandards
|
composer install --no-dev --no-interaction --quiet
|
||||||
echo "Using pre-installed /opt/moko-platform"
|
|
||||||
else
|
|
||||||
echo "::warning::MokoStandards tools not found on runner"
|
|
||||||
echo "MOKO_SKIP=true" >> "$GITHUB_ENV"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Read version from README.md
|
- name: Read version from README.md
|
||||||
id: version
|
id: version
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#
|
#
|
||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: MokoStandards.Notifications
|
# INGROUP: moko-platform.Notifications
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
# PATH: /.gitea/workflows/notify.yml
|
# PATH: /.gitea/workflows/notify.yml
|
||||||
# VERSION: 01.00.00
|
# VERSION: 01.00.00
|
||||||
# BRIEF: Push notifications via ntfy on release success or workflow failure
|
# BRIEF: Push notifications via ntfy on release success or workflow failure
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
|
|
||||||
name: "Publish to npm"
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
publish:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '20'
|
|
||||||
registry-url: 'https://registry.npmjs.org'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Auto-bump patch version
|
|
||||||
run: |
|
|
||||||
PKG_NAME=$(node -p "require('./package.json').name")
|
|
||||||
CURRENT=$(node -p "require('./package.json').version")
|
|
||||||
PUBLISHED=$(npm view "${PKG_NAME}@latest" version 2>/dev/null || echo "0.0.0")
|
|
||||||
if [ "$CURRENT" = "$PUBLISHED" ]; then
|
|
||||||
npm version patch --no-git-tag-version
|
|
||||||
NEW_VER=$(node -p "require('./package.json').version")
|
|
||||||
echo "Bumped ${CURRENT} -> ${NEW_VER}"
|
|
||||||
git config user.name "github-actions[bot]"
|
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
||||||
git add package.json
|
|
||||||
git commit -m "chore: bump to ${NEW_VER} [skip ci]"
|
|
||||||
git push
|
|
||||||
else
|
|
||||||
echo "Version ${CURRENT} not yet published, using as-is."
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
|
|
||||||
- name: Publish
|
|
||||||
run: npm publish --access public
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
||||||
@@ -8,4 +8,245 @@
|
|||||||
# 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: Auto pre-release on push to dev/alpha/beta/rc branches
|
# BRIEF: Auto pre-release on push to dev/alpha/beta/rc branches
|
||||||
|
|
||||||
|
name: "Universal: Pre-Release"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
- 'fix/**'
|
||||||
|
- 'patch/**'
|
||||||
|
- 'hotfix/**'
|
||||||
|
- 'bugfix/**'
|
||||||
|
- 'chore/**'
|
||||||
|
- alpha
|
||||||
|
- beta
|
||||||
|
- rc
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
stability:
|
||||||
|
description: 'Pre-release channel'
|
||||||
|
required: true
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- development
|
||||||
|
- alpha
|
||||||
|
- beta
|
||||||
|
- release-candidate
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
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 }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: "Build Pre-Release (${{ inputs.stability || github.ref_name }})"
|
||||||
|
runs-on: release
|
||||||
|
if: >-
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
github.event_name == 'push'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
|
ref: ${{ github.ref_name }}
|
||||||
|
|
||||||
|
- name: Setup moko-platform tools
|
||||||
|
env:
|
||||||
|
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
||||||
|
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
||||||
|
run: |
|
||||||
|
# Use pre-installed /opt/moko-platform if available (updated by cron every 6h)
|
||||||
|
if [ -f /opt/moko-platform/cli/version_bump.php ] && [ -f /opt/moko-platform/cli/manifest_element.php ] && [ -f /opt/moko-platform/vendor/autoload.php ]; then
|
||||||
|
echo Using pre-installed /opt/moko-platform
|
||||||
|
echo MOKO_CLI=/opt/moko-platform/cli >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo Falling back to fresh clone
|
||||||
|
if ! command -v composer > /dev/null 2>&1; 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
|
||||||
|
rm -rf /tmp/moko-platform-api
|
||||||
|
CLONE_URL=https://x-access-token:${MOKO_CLONE_TOKEN}@${MOKO_CLONE_HOST}/moko-platform.git
|
||||||
|
git clone --depth 1 --branch main --quiet $CLONE_URL /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: Detect platform
|
||||||
|
id: platform
|
||||||
|
run: |
|
||||||
|
# Auto-detect and update platform if not set in manifest
|
||||||
|
php ${MOKO_CLI}/platform_detect.php --path . --github-output 2>/dev/null || true
|
||||||
|
php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
||||||
|
|
||||||
|
- name: Resolve metadata and bump version
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
# Auto-detect stability from branch name on push, or use input on dispatch
|
||||||
|
if [ "${{ github.event_name }}" = "push" ]; then
|
||||||
|
case "${{ github.ref_name }}" in
|
||||||
|
rc) STABILITY="release-candidate" ;;
|
||||||
|
alpha) STABILITY="alpha" ;;
|
||||||
|
beta) STABILITY="beta" ;;
|
||||||
|
*) STABILITY="development" ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
STABILITY="${{ inputs.stability || 'development' }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$STABILITY" in
|
||||||
|
development) SUFFIX="-dev"; TAG="development" ;;
|
||||||
|
alpha) SUFFIX="-alpha"; TAG="alpha" ;;
|
||||||
|
beta) SUFFIX="-beta"; TAG="beta" ;;
|
||||||
|
release-candidate) SUFFIX="-rc"; TAG="release-candidate" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Bump version via CLI: patch for dev/alpha/beta, minor for RC
|
||||||
|
case "$STABILITY" in
|
||||||
|
release-candidate) BUMP="minor" ;;
|
||||||
|
*) BUMP="patch" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
php ${MOKO_CLI}/version_bump.php --path . $([ "$BUMP" = "minor" ] && echo "--minor") 2>/dev/null || true
|
||||||
|
|
||||||
|
# Set stability suffix and verify consistency
|
||||||
|
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "00.00.01")
|
||||||
|
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
||||||
|
|
||||||
|
php ${MOKO_CLI}/version_set_platform.php \
|
||||||
|
--path . --version "$VERSION" --branch "${{ github.ref_name }}" --stability "$STABILITY" 2>/dev/null || true
|
||||||
|
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
||||||
|
|
||||||
|
# Ensure licensing tags (updateservers, dlid) if enabled in manifest.xml
|
||||||
|
php ${MOKO_CLI}/manifest_licensing.php --path . --fix 2>/dev/null || true
|
||||||
|
|
||||||
|
# Append suffix for output
|
||||||
|
if [ -n "$SUFFIX" ]; then
|
||||||
|
VERSION="${VERSION}${SUFFIX}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Commit version bump
|
||||||
|
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
||||||
|
git config --local user.name "gitea-actions[bot]"
|
||||||
|
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
||||||
|
git add -A
|
||||||
|
git diff --cached --quiet || {
|
||||||
|
git commit -m "chore(version): pre-release bump to ${VERSION} [skip ci]"
|
||||||
|
git push origin HEAD 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Auto-detect element via manifest_element.php
|
||||||
|
php ${MOKO_CLI}/manifest_element.php \
|
||||||
|
--path . --version "$VERSION" --stability "$STABILITY" \
|
||||||
|
--repo "${GITEA_REPO}" --github-output
|
||||||
|
|
||||||
|
# Read back element outputs
|
||||||
|
EXT_ELEMENT=$(grep '^ext_element=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2)
|
||||||
|
ZIP_NAME=$(grep '^zip_name=' "$GITHUB_OUTPUT" | tail -1 | cut -d= -f2)
|
||||||
|
[ -z "$EXT_ELEMENT" ] && EXT_ELEMENT=$(echo "${GITEA_REPO}" | tr '[:upper:]' '[:lower:]' | tr -d ' -')
|
||||||
|
[ -z "$ZIP_NAME" ] && ZIP_NAME="${EXT_ELEMENT}-${VERSION}.zip"
|
||||||
|
|
||||||
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "zip_name=${ZIP_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "ext_element=${EXT_ELEMENT}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "=== Pre-Release: ${EXT_ELEMENT} ${VERSION}${SUFFIX} ==="
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
id: release
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
php ${MOKO_CLI}/release_create.php \
|
||||||
|
--path . --version "$VERSION" --tag "$TAG" \
|
||||||
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
|
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
|
||||||
|
|
||||||
|
- name: Update release notes from CHANGELOG.md
|
||||||
|
run: |
|
||||||
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
|
||||||
|
# Extract [Unreleased] section from changelog (everything between [Unreleased] and next ## heading)
|
||||||
|
if [ -f "CHANGELOG.md" ]; then
|
||||||
|
NOTES=$(awk '/^## \[Unreleased\]/{found=1; next} /^## \[/{if(found) exit} found{print}' CHANGELOG.md)
|
||||||
|
[ -z "$NOTES" ] && NOTES="Release ${VERSION}"
|
||||||
|
else
|
||||||
|
NOTES="Release ${VERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update release body via API
|
||||||
|
RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" \
|
||||||
|
"${API_BASE}/releases/tags/${TAG}" | python3 -c "import json,sys; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true)
|
||||||
|
|
||||||
|
if [ -n "$RELEASE_ID" ]; then
|
||||||
|
python3 -c "
|
||||||
|
import json, urllib.request
|
||||||
|
body = open('/dev/stdin').read()
|
||||||
|
payload = json.dumps({'body': body}).encode()
|
||||||
|
req = urllib.request.Request(
|
||||||
|
'${API_BASE}/releases/${RELEASE_ID}',
|
||||||
|
data=payload, method='PATCH',
|
||||||
|
headers={
|
||||||
|
'Authorization': 'token ${{ secrets.MOKOGITEA_TOKEN }}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
})
|
||||||
|
urllib.request.urlopen(req)
|
||||||
|
" <<< "$NOTES"
|
||||||
|
echo "Release notes updated from CHANGELOG.md"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Build package and upload
|
||||||
|
id: package
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
TAG="${{ steps.meta.outputs.tag }}"
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
php ${MOKO_CLI}/release_package.php \
|
||||||
|
--path . --version "$VERSION" --tag "$TAG" \
|
||||||
|
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
||||||
|
--repo "${GITEA_REPO}" --output /tmp || true
|
||||||
|
|
||||||
|
# updates.xml is generated dynamically by MokoGitea license server
|
||||||
|
# No need to build, commit, or sync updates.xml from workflows
|
||||||
|
|
||||||
|
- name: "Delete lesser pre-release channels (cascade)"
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
||||||
|
TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
||||||
|
|
||||||
|
php ${MOKO_CLI}/release_cascade.php \
|
||||||
|
--stability "${{ steps.meta.outputs.stability }}" \
|
||||||
|
--token "${TOKEN}" \
|
||||||
|
--api-base "${API_BASE}"
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
VERSION="${{ steps.meta.outputs.version }}"
|
||||||
|
STABILITY="${{ steps.meta.outputs.stability }}"
|
||||||
|
ZIP_NAME="${{ steps.meta.outputs.zip_name }}"
|
||||||
|
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
||||||
|
echo "## Pre-Release Complete" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Field | Value |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "|-------|-------|" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Version | \`${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Channel | ${STABILITY} |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| Package | \`${ZIP_NAME}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "| SHA-256 | \`${SHA256:-n/a}\` |" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
#
|
#
|
||||||
# FILE INFORMATION
|
# FILE INFORMATION
|
||||||
# DEFGROUP: Gitea.Workflow
|
# DEFGROUP: Gitea.Workflow
|
||||||
# INGROUP: MokoStandards.Security
|
# INGROUP: moko-platform.Security
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/MokoStandards
|
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
||||||
# PATH: /.gitea/workflows/security-audit.yml
|
# PATH: /.gitea/workflows/security-audit.yml
|
||||||
# VERSION: 01.00.00
|
# VERSION: 01.00.00
|
||||||
# BRIEF: Dependency vulnerability scanning for composer and npm packages
|
# BRIEF: Dependency vulnerability scanning for composer and npm packages
|
||||||
@@ -80,3 +80,19 @@ jobs:
|
|||||||
-H "Priority: high" \
|
-H "Priority: high" \
|
||||||
-d "Security audit found vulnerabilities. Review dependency updates." \
|
-d "Security audit found vulnerabilities. Review dependency updates." \
|
||||||
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
"${NTFY_URL}/${NTFY_TOPIC}" || true
|
||||||
|
|
||||||
|
|
||||||
|
- name: Joomla version audit
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -f "monitoring/joomla-version-audit.php" ] && [ -n "$JOOMLA_SITES" ]; then
|
||||||
|
echo "$JOOMLA_SITES" > /tmp/sites.json
|
||||||
|
php monitoring/joomla-version-audit.php --sites /tmp/sites.json || true
|
||||||
|
echo "### Joomla Version Audit" >> $GITHUB_STEP_SUMMARY
|
||||||
|
rm -f /tmp/sites.json
|
||||||
|
else
|
||||||
|
echo "Joomla audit skipped (no script or JOOMLA_SITES_JSON not configured)"
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
JOOMLA_SITES: ${{ vars.JOOMLA_SITES_JSON }}
|
||||||
|
|
||||||
|
|||||||
@@ -47,19 +47,22 @@ jobs:
|
|||||||
token: ${{ secrets.GH_TOKEN || github.token }}
|
token: ${{ secrets.GH_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@fcafdd6392932010c2bd5094439b8e33be2a8a09 # v2.37.0
|
||||||
|
with:
|
||||||
|
php-version: '8.1'
|
||||||
|
tools: composer
|
||||||
|
|
||||||
- name: Setup MokoStandards tools
|
- name: Setup MokoStandards tools
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
|
||||||
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || github.token }}"}}'
|
||||||
run: |
|
run: |
|
||||||
# Use pre-installed mokoplatform on runner host (symlink /opt/mokoplatform -> /opt/moko-platform)
|
git clone --depth 1 --branch version/04 --quiet \
|
||||||
if [ -d /opt/mokoplatform/api/cli ] && [ -f /opt/mokoplatform/vendor/autoload.php ]; then
|
"https://x-access-token:${GH_TOKEN}@github.com/mokoconsulting-tech/MokoStandards.git" \
|
||||||
ln -sf /opt/mokoplatform /tmp/mokostandards
|
/tmp/mokostandards
|
||||||
echo "Using pre-installed /opt/mokoplatform"
|
cd /tmp/mokostandards
|
||||||
elif [ -d /opt/moko-platform/api/cli ]; then
|
composer install --no-dev --no-interaction --quiet
|
||||||
ln -sf /opt/moko-platform /tmp/mokostandards
|
|
||||||
echo "Using pre-installed /opt/moko-platform"
|
|
||||||
else
|
|
||||||
echo "::warning::MokoStandards tools not found on runner - skipping"
|
|
||||||
echo "MOKO_SKIP=true" >> "$GITHUB_ENV"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Auto-bump patch version
|
- name: Auto-bump patch version
|
||||||
if: ${{ github.event_name == 'push' && github.actor != 'github-actions[bot]' }}
|
if: ${{ github.event_name == 'push' && github.actor != 'github-actions[bot]' }}
|
||||||
|
|||||||
@@ -1,312 +0,0 @@
|
|||||||
# Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
#
|
|
||||||
# FILE INFORMATION
|
|
||||||
# DEFGROUP: Gitea.Workflow
|
|
||||||
# INGROUP: moko-platform.Universal
|
|
||||||
# REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
|
||||||
# PATH: /templates/workflows/update-server.yml
|
|
||||||
# VERSION: 05.00.00
|
|
||||||
# BRIEF: Pre-release build + update server XML for dev/alpha/beta/rc branches
|
|
||||||
#
|
|
||||||
# Thin wrapper around moko-platform CLI tools.
|
|
||||||
# Builds packages, updates updates.xml, and optionally deploys via SFTP.
|
|
||||||
#
|
|
||||||
# Joomla filters update entries by the 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 Server
|
|
||||||
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.MOKOGITEA_TOKEN }}
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup moko-platform tools
|
|
||||||
env:
|
|
||||||
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
|
|
||||||
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
|
|
||||||
COMPOSER_AUTH: '{"http-basic":{"git.mokoconsulting.tech":{"username":"token","password":"${{ secrets.MOKOGITEA_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
|
|
||||||
# Always fetch latest CLI tools — never use stale cache from previous runs
|
|
||||||
rm -rf /tmp/moko-platform
|
|
||||||
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
|
|
||||||
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
|
|
||||||
echo "MOKO_CLI=/tmp/moko-platform/cli" >> "$GITHUB_ENV"
|
|
||||||
|
|
||||||
- name: Detect platform
|
|
||||||
id: platform
|
|
||||||
run: php ${MOKO_CLI}/manifest_read.php --path . --github-output
|
|
||||||
|
|
||||||
- name: Resolve stability and bump version
|
|
||||||
id: meta
|
|
||||||
run: |
|
|
||||||
BRANCH="${{ github.ref_name }}"
|
|
||||||
|
|
||||||
# Configure git for bot pushes
|
|
||||||
git config --local user.email "gitea-actions[bot]@mokoconsulting.tech"
|
|
||||||
git config --local user.name "gitea-actions[bot]"
|
|
||||||
git remote set-url origin "https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git"
|
|
||||||
|
|
||||||
# Auto-bump patch version
|
|
||||||
php ${MOKO_CLI}/version_bump.php --path . 2>/dev/null || true
|
|
||||||
|
|
||||||
VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "0.0.0")
|
|
||||||
|
|
||||||
# Strip any existing suffix before applying stability
|
|
||||||
VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//')
|
|
||||||
|
|
||||||
# Determine stability from branch or manual 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"
|
|
||||||
else
|
|
||||||
STABILITY="development"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Version suffix per stability stream
|
|
||||||
case "$STABILITY" in
|
|
||||||
development) SUFFIX="-dev"; TAG="development" ;;
|
|
||||||
alpha) SUFFIX="-alpha"; TAG="alpha" ;;
|
|
||||||
beta) SUFFIX="-beta"; TAG="beta" ;;
|
|
||||||
rc) SUFFIX="-rc"; TAG="release-candidate" ;;
|
|
||||||
*) SUFFIX=""; TAG="stable" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Propagate version with stability suffix to all manifest files
|
|
||||||
php ${MOKO_CLI}/version_set_platform.php \
|
|
||||||
--path . --version "$VERSION" --branch "$BRANCH" --stability "$STABILITY" 2>/dev/null || true
|
|
||||||
php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true
|
|
||||||
|
|
||||||
# Re-read version (now includes suffix from version_set_platform)
|
|
||||||
if [ -n "$SUFFIX" ]; then
|
|
||||||
VERSION="${VERSION}${SUFFIX}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "stability=${STABILITY}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "suffix=${SUFFIX}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "display_version=${VERSION}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
# Commit version bump if changed
|
|
||||||
git add -A
|
|
||||||
git diff --cached --quiet || {
|
|
||||||
git commit -m "chore(version): auto-bump ${VERSION} [skip ci]" \
|
|
||||||
--author="gitea-actions[bot] <gitea-actions[bot]@mokoconsulting.tech>"
|
|
||||||
git push
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Create release and upload package
|
|
||||||
id: package
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
TAG="${{ steps.meta.outputs.tag }}"
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
|
|
||||||
# Create or update Gitea release
|
|
||||||
php ${MOKO_CLI}/release_create.php \
|
|
||||||
--path . --version "$VERSION" --tag "$TAG" \
|
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
|
||||||
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
|
|
||||||
|
|
||||||
# Build package and upload
|
|
||||||
php ${MOKO_CLI}/release_package.php \
|
|
||||||
--path . --version "$VERSION" --tag "$TAG" \
|
|
||||||
--token "${{ secrets.MOKOGITEA_TOKEN }}" --api-base "$API_BASE" \
|
|
||||||
--repo "${GITEA_REPO}" --output /tmp || true
|
|
||||||
|
|
||||||
- name: Update updates.xml
|
|
||||||
if: steps.platform.outputs.platform == 'joomla'
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
|
||||||
SHA256="${{ steps.package.outputs.sha256_zip }}"
|
|
||||||
|
|
||||||
if [ ! -f "updates.xml" ]; then
|
|
||||||
echo "No updates.xml — skipping"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
SHA_FLAG=""
|
|
||||||
[ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}"
|
|
||||||
|
|
||||||
php ${MOKO_CLI}/updates_xml_build.php \
|
|
||||||
--path . --version "${VERSION}" --stability "${STABILITY}" \
|
|
||||||
--gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \
|
|
||||||
${SHA_FLAG}
|
|
||||||
|
|
||||||
# Commit and push updates.xml
|
|
||||||
git add updates.xml
|
|
||||||
git diff --cached --quiet || {
|
|
||||||
git commit -m "chore: update ${STABILITY} channel ${VERSION} [skip ci]"
|
|
||||||
git push
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Sync updates.xml to main
|
|
||||||
if: github.ref_name != 'main' && steps.platform.outputs.platform == 'joomla'
|
|
||||||
run: |
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
GITEA_TOKEN="${{ secrets.MOKOGITEA_TOKEN }}"
|
|
||||||
|
|
||||||
FILE_SHA=$(curl -sf -H "Authorization: token ${GITEA_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 ${{ steps.meta.outputs.stability }} [skip ci]',
|
|
||||||
'branch': 'main'
|
|
||||||
}).encode()
|
|
||||||
req = urllib.request.Request(
|
|
||||||
'${API_BASE}/contents/updates.xml',
|
|
||||||
data=payload, method='PUT',
|
|
||||||
headers={
|
|
||||||
'Authorization': 'token ${GITEA_TOKEN}',
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
})
|
|
||||||
try:
|
|
||||||
urllib.request.urlopen(req)
|
|
||||||
print('updates.xml synced to main')
|
|
||||||
except Exception as e:
|
|
||||||
print(f'WARNING: sync to main failed: {e}', file=sys.stderr)
|
|
||||||
"
|
|
||||||
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 }}"
|
|
||||||
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"
|
|
||||||
|
|
||||||
PERMISSION=$(curl -sf -H "Authorization: token ${{ secrets.MOKOGITEA_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 ${MOKO_CLI}/platform_detect.php --path . 2>/dev/null || true)
|
|
||||||
if [ "$PLATFORM" = "waas-component" ] && [ -f "${MOKO_CLI}/../deploy/deploy-joomla.php" ]; then
|
|
||||||
php ${MOKO_CLI}/../deploy/deploy-joomla.php --path . --src-dir "$SOURCE_DIR" --config /tmp/sftp-config.json
|
|
||||||
elif [ -f "${MOKO_CLI}/../deploy/deploy-sftp.php" ]; then
|
|
||||||
php ${MOKO_CLI}/../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: Summary
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
STABILITY="${{ steps.meta.outputs.stability }}"
|
|
||||||
DISPLAY="${{ steps.meta.outputs.display_version }}"
|
|
||||||
echo "## 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}\` |" >> $GITHUB_STEP_SUMMARY
|
|
||||||
-134
@@ -1,27 +1,7 @@
|
|||||||
<!-- Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
||||||
SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
DEFGROUP: gitea-api-mcp.Documentation
|
|
||||||
REPO: https://git.mokoconsulting.tech/MokoConsulting/gitea-api-mcp
|
|
||||||
-->
|
|
||||||
|
|
||||||
# Changelog
|
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
|
||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
|
||||||
- `gitea_org_issue_statuses_list` -- list issue status definitions for an org
|
|
||||||
- `gitea_org_issue_priorities_list` -- list issue priority definitions for an org
|
|
||||||
- `gitea_org_issue_types_list` -- list issue type definitions for an org
|
|
||||||
- `gitea_issue_set_status` -- set/clear status on an issue (convenience wrapper)
|
|
||||||
- `gitea_issue_set_priority` -- set/clear priority on an issue (convenience wrapper)
|
|
||||||
- `gitea_issue_create` now accepts `status_id`, `priority_id`, `type_id` params
|
|
||||||
- `gitea_issue_update` now accepts `status_id`, `priority_id`, `type_id` params
|
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Migrated all workflow and template paths from `.github/` to `.mokogitea/`
|
- Migrated all workflow and template paths from `.github/` to `.mokogitea/`
|
||||||
- Template source paths updated: `templates/gitea/` to `templates/mokogitea/`
|
- Template source paths updated: `templates/gitea/` to `templates/mokogitea/`
|
||||||
@@ -29,117 +9,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- `branch-cleanup.yml`: auto-delete merged feature branches after PR merge
|
- `branch-cleanup.yml`: auto-delete merged feature branches after PR merge
|
||||||
|
|
||||||
### Changed
|
|
||||||
- **Renamed** package from `@mokoconsulting/gitea-api-mcp` to `@mokoconsulting/mokogitea-api-mcp` to distinguish Moko's forked Gitea MCP from upstream
|
|
||||||
- **Renamed** McpServer name and bin entry to `mokogitea-api-mcp`
|
|
||||||
|
|
||||||
## [0.0.1] - 2026-05-07
|
|
||||||
|
|
||||||
### Added
|
|
||||||
|
|
||||||
#### User / Auth (3 tools)
|
|
||||||
- `gitea_me` -- Get the authenticated user info
|
|
||||||
- `gitea_user_orgs` -- List organizations the authenticated user belongs to
|
|
||||||
- `gitea_user_repos` -- List repositories owned by the authenticated user
|
|
||||||
|
|
||||||
#### Repositories (8 tools)
|
|
||||||
- `gitea_repo_get` -- Get repository details
|
|
||||||
- `gitea_repo_create` -- Create a new repository
|
|
||||||
- `gitea_repo_delete` -- Delete a repository
|
|
||||||
- `gitea_repo_edit` -- Edit repository settings
|
|
||||||
- `gitea_repo_fork` -- Fork a repository
|
|
||||||
- `gitea_repo_search` -- Search repositories
|
|
||||||
- `gitea_org_repos` -- List repositories in an organization
|
|
||||||
- `gitea_list_connections` -- List configured Gitea connections
|
|
||||||
|
|
||||||
#### File Contents (5 tools)
|
|
||||||
- `gitea_file_get` -- Get file contents from a repository
|
|
||||||
- `gitea_dir_get` -- Get directory contents (file listing) from a repository
|
|
||||||
- `gitea_file_create_or_update` -- Create or update a file in a repository
|
|
||||||
- `gitea_file_delete` -- Delete a file from a repository
|
|
||||||
- `gitea_tree_get` -- Get the git tree for a repository (recursive file listing)
|
|
||||||
|
|
||||||
#### Branches (4 tools)
|
|
||||||
- `gitea_branches_list` -- List branches in a repository
|
|
||||||
- `gitea_branch_get` -- Get a specific branch
|
|
||||||
- `gitea_branch_create` -- Create a new branch
|
|
||||||
- `gitea_branch_delete` -- Delete a branch
|
|
||||||
|
|
||||||
#### Commits (2 tools)
|
|
||||||
- `gitea_commits_list` -- List commits in a repository
|
|
||||||
- `gitea_commit_get` -- Get a specific commit
|
|
||||||
|
|
||||||
#### Issues (7 tools)
|
|
||||||
- `gitea_issues_list` -- List issues in a repository
|
|
||||||
- `gitea_issue_get` -- Get a single issue by number
|
|
||||||
- `gitea_issue_create` -- Create a new issue
|
|
||||||
- `gitea_issue_update` -- Update an issue
|
|
||||||
- `gitea_issue_comments_list` -- List comments on an issue
|
|
||||||
- `gitea_issue_comment_create` -- Add a comment to an issue
|
|
||||||
- `gitea_issue_search` -- Search issues across all repositories
|
|
||||||
|
|
||||||
#### Labels (2 tools)
|
|
||||||
- `gitea_labels_list` -- List labels in a repository
|
|
||||||
- `gitea_label_create` -- Create a label
|
|
||||||
|
|
||||||
#### Milestones (2 tools)
|
|
||||||
- `gitea_milestones_list` -- List milestones in a repository
|
|
||||||
- `gitea_milestone_create` -- Create a milestone
|
|
||||||
|
|
||||||
#### Pull Requests (6 tools)
|
|
||||||
- `gitea_pulls_list` -- List pull requests
|
|
||||||
- `gitea_pull_get` -- Get a single pull request
|
|
||||||
- `gitea_pull_create` -- Create a pull request
|
|
||||||
- `gitea_pull_merge` -- Merge a pull request
|
|
||||||
- `gitea_pull_files` -- List files changed in a pull request
|
|
||||||
- `gitea_pull_review_create` -- Create a pull request review
|
|
||||||
|
|
||||||
#### Releases (5 tools)
|
|
||||||
- `gitea_releases_list` -- List releases
|
|
||||||
- `gitea_release_get` -- Get a single release by ID
|
|
||||||
- `gitea_release_latest` -- Get the latest release
|
|
||||||
- `gitea_release_create` -- Create a new release
|
|
||||||
- `gitea_release_delete` -- Delete a release
|
|
||||||
|
|
||||||
#### Tags (3 tools)
|
|
||||||
- `gitea_tags_list` -- List tags
|
|
||||||
- `gitea_tag_create` -- Create a tag
|
|
||||||
- `gitea_tag_delete` -- Delete a tag
|
|
||||||
|
|
||||||
#### Actions (2 tools)
|
|
||||||
- `gitea_actions_runs_list` -- List workflow runs for a repository
|
|
||||||
- `gitea_actions_run_get` -- Get a specific workflow run
|
|
||||||
|
|
||||||
#### Organizations (3 tools)
|
|
||||||
- `gitea_org_get` -- Get organization details
|
|
||||||
- `gitea_org_teams_list` -- List teams in an organization
|
|
||||||
- `gitea_org_members_list` -- List members of an organization
|
|
||||||
|
|
||||||
#### Users (2 tools)
|
|
||||||
- `gitea_user_get` -- Get a user profile
|
|
||||||
- `gitea_users_search` -- Search users
|
|
||||||
|
|
||||||
#### Webhooks (2 tools)
|
|
||||||
- `gitea_webhooks_list` -- List webhooks for a repository
|
|
||||||
- `gitea_webhook_create` -- Create a webhook
|
|
||||||
|
|
||||||
#### Wiki (2 tools)
|
|
||||||
- `gitea_wiki_pages_list` -- List wiki pages
|
|
||||||
- `gitea_wiki_page_get` -- Get a wiki page
|
|
||||||
|
|
||||||
#### Notifications (2 tools)
|
|
||||||
- `gitea_notifications_list` -- List notifications for the authenticated user
|
|
||||||
- `gitea_notifications_read` -- Mark all notifications as read
|
|
||||||
|
|
||||||
#### Generic (2 tools)
|
|
||||||
- `gitea_api_request` -- Make a raw API request to any Gitea v1 endpoint
|
|
||||||
- `gitea_list_connections` -- List configured Gitea connections
|
|
||||||
|
|
||||||
### Infrastructure
|
|
||||||
- Multi-connection config support via `~/.gitea-api-mcp.json`
|
|
||||||
- Token-based authentication (Gitea native `Authorization: token` header)
|
|
||||||
- Built on `node:https` / `node:http` (zero HTTP dependencies)
|
|
||||||
- MCP SDK v1.12.x with stdio transport
|
|
||||||
|
|
||||||
[0.0.1]: https://git.mokoconsulting.tech/MokoConsulting/gitea-api-mcp/releases/tag/v0.0.1
|
|
||||||
|
|||||||
+189
-161
@@ -1,161 +1,189 @@
|
|||||||
# Contributing to Moko Consulting Projects
|
<!-- Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
Thank you for your interest in contributing. All Moko Consulting repositories follow this universal workflow and version policy.
|
DEFGROUP: gitea-api-mcp.Documentation
|
||||||
|
REPO: https://git.mokoconsulting.tech/MokoConsulting/gitea-api-mcp
|
||||||
## Branching Workflow
|
-->
|
||||||
|
|
||||||
```
|
# Contributing to gitea-api-mcp
|
||||||
feature/* ──PR──> dev ──draft PR──> (renamed to rc) ──merge──> main
|
|
||||||
```
|
Thank you for your interest in contributing to gitea-api-mcp. This document provides guidelines and information for contributors.
|
||||||
|
|
||||||
### Step by step
|
## Table of Contents
|
||||||
|
|
||||||
1. **Create a feature branch** from `dev`:
|
- [Getting Started](#getting-started)
|
||||||
```bash
|
- [Development Setup](#development-setup)
|
||||||
git checkout dev && git pull
|
- [Gitea API Explorer](#gitea-api-explorer)
|
||||||
git checkout -b feature/my-change
|
- [Code Style](#code-style)
|
||||||
```
|
- [Commit Conventions](#commit-conventions)
|
||||||
|
- [Branch Protection Rules](#branch-protection-rules)
|
||||||
2. **Work and commit** on your feature branch. Push to origin.
|
- [Pull Request Process](#pull-request-process)
|
||||||
|
- [Adding a New Tool](#adding-a-new-tool)
|
||||||
3. **Open a PR**: `feature/my-change` → `dev`. After review and checks, merge it.
|
|
||||||
|
## Getting Started
|
||||||
4. **When ready for release**, open a **draft PR**: `dev` → `main`.
|
|
||||||
- This automatically renames the source branch to `rc` (release candidate)
|
1. Fork the repository on Gitea: https://git.mokoconsulting.tech/MokoConsulting/gitea-api-mcp
|
||||||
- An RC pre-release is built and uploaded
|
2. Clone your fork locally
|
||||||
|
3. Create a feature branch from `main`
|
||||||
5. **Alpha and beta branches** are created by manually renaming the branch before the RC stage:
|
4. Make your changes
|
||||||
- Rename `dev` to `alpha` for early testing → alpha pre-release is built
|
5. Submit a pull request
|
||||||
- Rename `alpha` to `beta` for feature-complete testing → beta pre-release is built
|
|
||||||
- When the draft PR is created, the branch is renamed to `rc`
|
## Development Setup
|
||||||
|
|
||||||
6. **Once PR checks pass** on the `rc` branch, mark the PR as ready and merge to `main`.
|
```bash
|
||||||
|
git clone https://git.mokoconsulting.tech/YourUsername/gitea-api-mcp.git
|
||||||
7. **Merging to main** triggers the stable release pipeline:
|
cd gitea-api-mcp
|
||||||
- Minor version bump (e.g., `02.09.xx` → `02.10.00`)
|
npm install
|
||||||
- Stability suffix stripped (clean version)
|
npm run build
|
||||||
- Gitea release created with ZIP/tar.gz packages
|
```
|
||||||
- `updates.xml` updated (Joomla extensions)
|
|
||||||
- `dev` branch recreated from `main`
|
For live recompilation during development:
|
||||||
|
|
||||||
### Branch summary
|
```bash
|
||||||
|
npm run dev
|
||||||
| Branch | Purpose | Created by |
|
```
|
||||||
|--------|---------|-----------|
|
|
||||||
| `feature/*` | New features and fixes | Developer |
|
Ensure you have a valid `~/.gitea-api-mcp.json` config file pointing to a test Gitea instance before testing.
|
||||||
| `dev` | Integration branch | Auto-recreated after release |
|
|
||||||
| `alpha` | Alpha pre-release testing | Manual rename from `dev` |
|
## Gitea API Explorer
|
||||||
| `beta` | Beta pre-release testing | Manual rename from `alpha` |
|
|
||||||
| `rc` | Release candidate | Auto-renamed on draft PR to main |
|
When adding or modifying tools, refer to your Gitea instance's built-in API explorer:
|
||||||
| `main` | Stable releases | Protected, merge only |
|
|
||||||
| `version/XX.YY.ZZ` | Archived release snapshots | Auto-created by CI |
|
```
|
||||||
|
https://your-gitea-instance/api/swagger
|
||||||
### Protected branches
|
```
|
||||||
|
|
||||||
| Branch | Direct push | Merge via |
|
For the Moko Consulting instance:
|
||||||
|--------|------------|-----------|
|
|
||||||
| `main` | Blocked (CI bot whitelisted) | PR merge only |
|
```
|
||||||
| `dev` | Blocked (CI bot whitelisted) | PR merge from feature/* |
|
https://git.mokoconsulting.tech/api/swagger
|
||||||
| `rc` | Blocked (CI bot whitelisted) | Auto-created on draft PR |
|
```
|
||||||
| `alpha` | Blocked (CI bot whitelisted) | Manual rename |
|
|
||||||
| `beta` | Blocked (CI bot whitelisted) | Manual rename |
|
The Swagger UI provides:
|
||||||
| `feature/*` | Open | N/A (source branch) |
|
- Full endpoint documentation with request/response schemas
|
||||||
|
- Interactive API testing ("Try it out" button)
|
||||||
## Version Policy
|
- Authentication configuration for testing
|
||||||
|
- Parameter type and validation details
|
||||||
### Format
|
|
||||||
|
## Code Style
|
||||||
All versions use `XX.YY.ZZ` — three two-digit segments, zero-padded:
|
|
||||||
|
- Use TypeScript strict mode
|
||||||
- **XX** — Major version (breaking changes)
|
- Follow the existing patterns in `src/index.ts` for tool registration
|
||||||
- **YY** — Minor version (new features, bumped on release to main)
|
- Use the `OwnerRepo`, `PaginationParams`, and `ConnectionParam` shared parameter objects
|
||||||
- **ZZ** — Patch version (auto-incremented on every push to dev/feature branches)
|
- Format responses through `formatResponse()`
|
||||||
|
- Include mokostandards file headers on all new source files
|
||||||
Rollover: patch `99` → `00` increments minor; minor `99` → `00` increments major.
|
|
||||||
|
### File Header Template
|
||||||
### Stability suffixes
|
|
||||||
|
```typescript
|
||||||
Each branch appends a suffix to indicate stability:
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
|
*
|
||||||
| Branch | Suffix | Example |
|
* This file is part of a Moko Consulting project.
|
||||||
|--------|--------|---------|
|
*
|
||||||
| `main` | (none) | `02.09.00` |
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
| `dev` | `-dev` | `02.09.01-dev` |
|
*
|
||||||
| `feature/*` | `-dev` | `02.09.01-dev` |
|
* FILE INFORMATION
|
||||||
| `alpha` | `-alpha` | `02.09.01-alpha` |
|
* DEFGROUP: gitea-api-mcp.<GroupName>
|
||||||
| `beta` | `-beta` | `02.09.01-beta` |
|
* INGROUP: gitea-api-mcp
|
||||||
| `rc` | `-rc` | `02.09.01-rc` |
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/gitea-api-mcp
|
||||||
|
* PATH: /src/<filename>.ts
|
||||||
### Auto version bump
|
* VERSION: 01.00.00
|
||||||
|
* BRIEF: <One-line description>
|
||||||
On every push to `dev`, `feature/*`, or `patch/*`:
|
*/
|
||||||
|
```
|
||||||
1. Patch version incremented
|
|
||||||
2. Stability suffix `-dev` applied
|
## Commit Conventions
|
||||||
3. All version-bearing files updated (manifests, CHANGELOG, PHP headers, etc.)
|
|
||||||
4. Commit created with `[skip ci]` to avoid loops
|
This project uses [Conventional Commits](https://www.conventionalcommits.org/):
|
||||||
|
|
||||||
### Release version flow
|
```
|
||||||
|
<type>(<scope>): <description>
|
||||||
Version bumps happen at specific release events:
|
|
||||||
|
[optional body]
|
||||||
| Event | Bump | Example |
|
|
||||||
|-------|------|---------|
|
[optional footer(s)]
|
||||||
| Feature merged to dev | Patch bump after dev release | `02.09.01-dev` → release → `02.09.02-dev` |
|
```
|
||||||
| Dev promoted to RC | Minor bump | `02.09.02-dev` → `02.10.00-rc` |
|
|
||||||
| RC merged to main | Minor bump | `02.10.00-rc` → `02.11.00` (stable) |
|
### Types
|
||||||
| Dev recreated from main | Patch bump | `02.11.00` → `02.11.01-dev` |
|
|
||||||
|
| Type | Description |
|
||||||
### Release stream copies
|
|------|-------------|
|
||||||
|
| `feat` | New feature (new tool, new parameter) |
|
||||||
When a higher-stability release is published, copies are created for all lesser streams with the same base version:
|
| `fix` | Bug fix |
|
||||||
|
| `docs` | Documentation only |
|
||||||
- **RC `02.10.00-rc`** also creates: `02.10.00-dev`, `02.10.00-alpha`, `02.10.00-beta`
|
| `refactor` | Code change that neither fixes a bug nor adds a feature |
|
||||||
- **Stable `02.11.00`** also creates: `02.11.00-dev`, `02.11.00-alpha`, `02.11.00-beta`, `02.11.00-rc`
|
| `chore` | Build process, dependency updates |
|
||||||
|
| `test` | Adding or updating tests |
|
||||||
This ensures Joomla sites on ANY stability channel see the update (Joomla only shows versions higher than what's installed).
|
|
||||||
|
### Scope
|
||||||
### Version files
|
|
||||||
|
Use the tool category as scope when applicable:
|
||||||
The version tools update all files containing version stamps:
|
|
||||||
|
```
|
||||||
- `.mokogitea/manifest.xml` (canonical source)
|
feat(issues): add gitea_issue_lock tool
|
||||||
- Joomla XML manifests (`<version>` tag)
|
fix(client): handle 204 No Content responses
|
||||||
- `README.md`, `CHANGELOG.md` (`VERSION:` pattern)
|
docs(readme): update tool count
|
||||||
- `package.json`, `pyproject.toml`
|
```
|
||||||
- Any text file with a `VERSION: XX.YY.ZZ` label
|
|
||||||
|
## Branch Protection Rules
|
||||||
Files synced from other repos (with a `# REPO:` header) are not touched.
|
|
||||||
|
The `main` branch has the following protections:
|
||||||
## Code Standards
|
|
||||||
|
- Direct pushes to `main` are not allowed
|
||||||
- **PHP**: PSR-12, tabs for indentation
|
- All changes must come through pull requests
|
||||||
- **Copyright**: all files must include the Moko Consulting copyright header
|
- At least one approval is required before merging
|
||||||
- **License**: SPDX identifier `GPL-3.0-or-later` (or as specified per repo)
|
- Status checks must pass before merging
|
||||||
- **Attribution**: use `Authored-by: Moko Consulting` in commits, not individual names
|
- Force pushes are disabled
|
||||||
|
|
||||||
## Commit Messages
|
### Branch Naming
|
||||||
|
|
||||||
Use conventional commit format:
|
```
|
||||||
|
feat/short-description
|
||||||
```
|
fix/issue-number-description
|
||||||
type(scope): short description
|
docs/what-changed
|
||||||
|
refactor/what-changed
|
||||||
Optional body with context.
|
```
|
||||||
|
|
||||||
Authored-by: Moko Consulting
|
## Pull Request Process
|
||||||
```
|
|
||||||
|
1. Ensure your branch is up to date with `main`
|
||||||
Types: `feat`, `fix`, `chore`, `docs`, `style`, `refactor`, `test`, `ci`
|
2. Update documentation if you added or changed tools
|
||||||
|
3. Update `CHANGELOG.md` under an `[Unreleased]` section
|
||||||
Special flags in commit messages:
|
4. Fill out the PR template with a clear description
|
||||||
- `[skip ci]` — skip all CI workflows
|
5. Request review from a maintainer
|
||||||
- `[skip bump]` — skip auto version bump only
|
6. Address any review feedback
|
||||||
|
7. Squash-merge will be used for final integration
|
||||||
## Reporting Issues
|
|
||||||
|
## Adding a New Tool
|
||||||
Use the repository's issue tracker with the appropriate template.
|
|
||||||
|
1. Identify the Gitea API endpoint in the Swagger explorer
|
||||||
---
|
2. Add the tool registration in `src/index.ts` under the appropriate category section
|
||||||
|
3. Follow the existing parameter patterns:
|
||||||
*Moko Consulting <hello@mokoconsulting.tech>*
|
- Use `OwnerRepo` for tools that operate on a specific repository
|
||||||
|
- Use `PaginationParams` for list endpoints
|
||||||
|
- Always include `ConnectionParam` for multi-connection support
|
||||||
|
4. Use `z.string().describe('...')` for all parameters with clear descriptions
|
||||||
|
5. Route through `formatResponse()` for consistent output
|
||||||
|
6. Update the tool tables in `README.md` and `docs/API.md`
|
||||||
|
7. Add the tool to `CHANGELOG.md`
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
server.tool(
|
||||||
|
'gitea_example_action',
|
||||||
|
'Description of what this tool does',
|
||||||
|
{
|
||||||
|
...OwnerRepo,
|
||||||
|
some_param: z.string().describe('What this parameter controls'),
|
||||||
|
...PaginationParams,
|
||||||
|
...ConnectionParam,
|
||||||
|
},
|
||||||
|
async ({ owner, repo, some_param, page, limit, connection }) => {
|
||||||
|
const params: Record<string, string> = { ...pageQuery({ page, limit }) };
|
||||||
|
if (some_param) params['some_param'] = some_param;
|
||||||
|
return formatResponse(
|
||||||
|
await clientFor(connection).get(`/repos/${owner}/${repo}/example`, params),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mokoconsulting/mcp-mokogitea-api",
|
"name": "@mokoconsulting/mcp-mokogitea-api",
|
||||||
"version": "1.3.0",
|
"version": "1.0.0",
|
||||||
"description": "MCP server for Gitea REST API v1 operations",
|
"description": "MCP server for Gitea REST API v1 operations",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
+2
-2
@@ -51,8 +51,8 @@ export class GiteaClient {
|
|||||||
return this.request(this.buildUrl(endpoint), 'PUT', body);
|
return this.request(this.buildUrl(endpoint), 'PUT', body);
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(endpoint: string, body?: unknown): Promise<ApiResponse> {
|
async delete(endpoint: string): Promise<ApiResponse> {
|
||||||
return this.request(this.buildUrl(endpoint), 'DELETE', body);
|
return this.request(this.buildUrl(endpoint), 'DELETE');
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildUrl(endpoint: string, params?: Record<string, string>): string {
|
private buildUrl(endpoint: string, params?: Record<string, string>): string {
|
||||||
|
|||||||
+12
-120
@@ -309,7 +309,8 @@ server.tool(
|
|||||||
const client = clientFor(connection);
|
const client = clientFor(connection);
|
||||||
const body: Record<string, unknown> = { sha, message };
|
const body: Record<string, unknown> = { sha, message };
|
||||||
if (branch) body.branch = branch;
|
if (branch) body.branch = branch;
|
||||||
return formatResponse(await client.delete(`/repos/${owner}/${repo}/contents/${filepath}`, body));
|
// Gitea DELETE with body needs special handling
|
||||||
|
return formatResponse(await client.post(`/repos/${owner}/${repo}/contents/${filepath}`, { ...body, _method: 'DELETE' }));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -435,30 +436,24 @@ server.tool(
|
|||||||
...OwnerRepo,
|
...OwnerRepo,
|
||||||
title: z.string().describe('Issue title'),
|
title: z.string().describe('Issue title'),
|
||||||
body: z.string().optional().describe('Issue body (markdown)'),
|
body: z.string().optional().describe('Issue body (markdown)'),
|
||||||
labels: z.array(z.union([z.number(), z.string()])).optional().describe('Label IDs or names (use gitea_labels_list to discover available labels)'),
|
labels: z.array(z.number()).optional().describe('Label IDs'),
|
||||||
milestone: z.number().optional().describe('Milestone ID'),
|
milestone: z.number().optional().describe('Milestone ID'),
|
||||||
assignees: z.array(z.string()).optional().describe('Usernames to assign'),
|
assignees: z.array(z.string()).optional().describe('Usernames to assign'),
|
||||||
status_id: z.number().optional().describe('Issue status definition ID (use gitea_org_issue_statuses_list to discover)'),
|
|
||||||
priority_id: z.number().optional().describe('Issue priority definition ID (use gitea_org_issue_priorities_list to discover)'),
|
|
||||||
type_id: z.number().optional().describe('Issue type definition ID (use gitea_org_issue_types_list to discover)'),
|
|
||||||
...ConnectionParam,
|
...ConnectionParam,
|
||||||
},
|
},
|
||||||
async ({ owner, repo, title, body: issueBody, labels, milestone, assignees, status_id, priority_id, type_id, connection }) => {
|
async ({ owner, repo, title, body: issueBody, labels, milestone, assignees, connection }) => {
|
||||||
const body: Record<string, unknown> = { title };
|
const body: Record<string, unknown> = { title };
|
||||||
if (issueBody) body.body = issueBody;
|
if (issueBody) body.body = issueBody;
|
||||||
if (labels) body.labels = labels;
|
if (labels) body.labels = labels;
|
||||||
if (milestone) body.milestone = milestone;
|
if (milestone) body.milestone = milestone;
|
||||||
if (assignees) body.assignees = assignees;
|
if (assignees) body.assignees = assignees;
|
||||||
if (status_id !== undefined) body.status_id = status_id;
|
|
||||||
if (priority_id !== undefined) body.priority_id = priority_id;
|
|
||||||
if (type_id !== undefined) body.type_id = type_id;
|
|
||||||
return formatResponse(await clientFor(connection).post(`/repos/${owner}/${repo}/issues`, body));
|
return formatResponse(await clientFor(connection).post(`/repos/${owner}/${repo}/issues`, body));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
server.tool(
|
server.tool(
|
||||||
'gitea_issue_update',
|
'gitea_issue_update',
|
||||||
'Update an issue (supports title, body, state, assignees, milestone, and org-level metadata)',
|
'Update an issue',
|
||||||
{
|
{
|
||||||
...OwnerRepo,
|
...OwnerRepo,
|
||||||
number: z.number().describe('Issue number'),
|
number: z.number().describe('Issue number'),
|
||||||
@@ -467,53 +462,19 @@ server.tool(
|
|||||||
state: z.enum(['open', 'closed']).optional().describe('State'),
|
state: z.enum(['open', 'closed']).optional().describe('State'),
|
||||||
assignees: z.array(z.string()).optional().describe('Assignees'),
|
assignees: z.array(z.string()).optional().describe('Assignees'),
|
||||||
milestone: z.number().optional().describe('Milestone ID'),
|
milestone: z.number().optional().describe('Milestone ID'),
|
||||||
status_id: z.number().optional().describe('Issue status definition ID (use gitea_org_issue_statuses_list to discover; 0 to clear)'),
|
|
||||||
priority_id: z.number().optional().describe('Issue priority definition ID (use gitea_org_issue_priorities_list to discover; 0 to clear)'),
|
|
||||||
type_id: z.number().optional().describe('Issue type definition ID (use gitea_org_issue_types_list to discover; 0 to clear)'),
|
|
||||||
...ConnectionParam,
|
...ConnectionParam,
|
||||||
},
|
},
|
||||||
async ({ owner, repo, number, title, body: issueBody, state, assignees, milestone, status_id, priority_id, type_id, connection }) => {
|
async ({ owner, repo, number, title, body: issueBody, state, assignees, milestone, connection }) => {
|
||||||
const body: Record<string, unknown> = {};
|
const body: Record<string, unknown> = {};
|
||||||
if (title !== undefined) body.title = title;
|
if (title !== undefined) body.title = title;
|
||||||
if (issueBody !== undefined) body.body = issueBody;
|
if (issueBody !== undefined) body.body = issueBody;
|
||||||
if (state) body.state = state;
|
if (state) body.state = state;
|
||||||
if (assignees) body.assignees = assignees;
|
if (assignees) body.assignees = assignees;
|
||||||
if (milestone !== undefined) body.milestone = milestone;
|
if (milestone !== undefined) body.milestone = milestone;
|
||||||
if (status_id !== undefined) body.status_id = status_id;
|
|
||||||
if (priority_id !== undefined) body.priority_id = priority_id;
|
|
||||||
if (type_id !== undefined) body.type_id = type_id;
|
|
||||||
return formatResponse(await clientFor(connection).patch(`/repos/${owner}/${repo}/issues/${number}`, body));
|
return formatResponse(await clientFor(connection).patch(`/repos/${owner}/${repo}/issues/${number}`, body));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_issue_set_status',
|
|
||||||
'Set or clear the status on an issue (convenience wrapper around issue update)',
|
|
||||||
{
|
|
||||||
...OwnerRepo,
|
|
||||||
number: z.number().describe('Issue number'),
|
|
||||||
status_id: z.number().describe('Status definition ID (0 to clear)'),
|
|
||||||
...ConnectionParam,
|
|
||||||
},
|
|
||||||
async ({ owner, repo, number, status_id, connection }) => {
|
|
||||||
return formatResponse(await clientFor(connection).patch(`/repos/${owner}/${repo}/issues/${number}`, { status_id }));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_issue_set_priority',
|
|
||||||
'Set or clear the priority on an issue (convenience wrapper around issue update)',
|
|
||||||
{
|
|
||||||
...OwnerRepo,
|
|
||||||
number: z.number().describe('Issue number'),
|
|
||||||
priority_id: z.number().describe('Priority definition ID (0 to clear)'),
|
|
||||||
...ConnectionParam,
|
|
||||||
},
|
|
||||||
async ({ owner, repo, number, priority_id, connection }) => {
|
|
||||||
return formatResponse(await clientFor(connection).patch(`/repos/${owner}/${repo}/issues/${number}`, { priority_id }));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
server.tool(
|
server.tool(
|
||||||
'gitea_issue_comments_list',
|
'gitea_issue_comments_list',
|
||||||
'List comments on an issue',
|
'List comments on an issue',
|
||||||
@@ -541,7 +502,7 @@ server.tool(
|
|||||||
{
|
{
|
||||||
q: z.string().describe('Search query'),
|
q: z.string().describe('Search query'),
|
||||||
state: z.enum(['open', 'closed', 'all']).optional().describe('State filter'),
|
state: z.enum(['open', 'closed', 'all']).optional().describe('State filter'),
|
||||||
labels: z.string().optional().describe('Comma-separated label IDs or names'),
|
labels: z.string().optional().describe('Comma-separated label IDs'),
|
||||||
type: z.enum(['issues', 'pulls']).optional().describe('Filter type'),
|
type: z.enum(['issues', 'pulls']).optional().describe('Filter type'),
|
||||||
...PaginationParams,
|
...PaginationParams,
|
||||||
...ConnectionParam,
|
...ConnectionParam,
|
||||||
@@ -559,7 +520,7 @@ server.tool(
|
|||||||
|
|
||||||
server.tool(
|
server.tool(
|
||||||
'gitea_labels_list',
|
'gitea_labels_list',
|
||||||
'List all labels in a repository (includes id, name, color, description — use to discover available type/priority/status labels)',
|
'List labels in a repository',
|
||||||
{ ...OwnerRepo, ...PaginationParams, ...ConnectionParam },
|
{ ...OwnerRepo, ...PaginationParams, ...ConnectionParam },
|
||||||
async ({ owner, repo, page, limit, connection }) => formatResponse(await clientFor(connection).get(`/repos/${owner}/${repo}/labels`, pageQuery({ page, limit }))),
|
async ({ owner, repo, page, limit, connection }) => formatResponse(await clientFor(connection).get(`/repos/${owner}/${repo}/labels`, pageQuery({ page, limit }))),
|
||||||
);
|
);
|
||||||
@@ -657,7 +618,7 @@ server.tool(
|
|||||||
head: z.string().describe('Source branch'),
|
head: z.string().describe('Source branch'),
|
||||||
base: z.string().describe('Target branch'),
|
base: z.string().describe('Target branch'),
|
||||||
body: z.string().optional().describe('PR description (markdown)'),
|
body: z.string().optional().describe('PR description (markdown)'),
|
||||||
labels: z.array(z.union([z.number(), z.string()])).optional().describe('Label IDs or names (use gitea_labels_list to discover available labels)'),
|
labels: z.array(z.number()).optional().describe('Label IDs'),
|
||||||
milestone: z.number().optional().describe('Milestone ID'),
|
milestone: z.number().optional().describe('Milestone ID'),
|
||||||
assignees: z.array(z.string()).optional().describe('Assignees'),
|
assignees: z.array(z.string()).optional().describe('Assignees'),
|
||||||
...ConnectionParam,
|
...ConnectionParam,
|
||||||
@@ -969,29 +930,6 @@ server.tool(
|
|||||||
async ({ org, page, limit, connection }) => formatResponse(await clientFor(connection).get(`/orgs/${org}/members`, pageQuery({ page, limit }))),
|
async ({ org, page, limit, connection }) => formatResponse(await clientFor(connection).get(`/orgs/${org}/members`, pageQuery({ page, limit }))),
|
||||||
);
|
);
|
||||||
|
|
||||||
// ── Organization Issue Metadata ──────────────────────────────────────────
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_org_issue_statuses_list',
|
|
||||||
'List issue status definitions for an organization (id, name, color, closes_issue — use to discover valid status_id values)',
|
|
||||||
{ org: z.string().describe('Organization name'), ...ConnectionParam },
|
|
||||||
async ({ org, connection }) => formatResponse(await clientFor(connection).get(`/orgs/${org}/issue-statuses`)),
|
|
||||||
);
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_org_issue_priorities_list',
|
|
||||||
'List issue priority definitions for an organization (id, name, color, is_default — use to discover valid priority_id values)',
|
|
||||||
{ org: z.string().describe('Organization name'), ...ConnectionParam },
|
|
||||||
async ({ org, connection }) => formatResponse(await clientFor(connection).get(`/orgs/${org}/issue-priorities`)),
|
|
||||||
);
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_org_issue_types_list',
|
|
||||||
'List issue type definitions for an organization (id, name, color, is_default — use to discover valid type_id values)',
|
|
||||||
{ org: z.string().describe('Organization name'), ...ConnectionParam },
|
|
||||||
async ({ org, connection }) => formatResponse(await clientFor(connection).get(`/orgs/${org}/issue-types`)),
|
|
||||||
);
|
|
||||||
|
|
||||||
// ── Users ───────────────────────────────────────────────────────────────
|
// ── Users ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
server.tool(
|
server.tool(
|
||||||
@@ -1241,7 +1179,7 @@ server.tool(
|
|||||||
|
|
||||||
server.tool(
|
server.tool(
|
||||||
'gitea_org_labels_list',
|
'gitea_org_labels_list',
|
||||||
'List labels for an organization (shared across repos — includes id, name, color, description for type/priority/status discovery)',
|
'List labels for an organization (shared across repos)',
|
||||||
{
|
{
|
||||||
org: z.string().describe('Organization name'),
|
org: z.string().describe('Organization name'),
|
||||||
...PaginationParams,
|
...PaginationParams,
|
||||||
@@ -1551,7 +1489,7 @@ server.tool(
|
|||||||
{
|
{
|
||||||
...OwnerRepo,
|
...OwnerRepo,
|
||||||
number: z.number().describe('Issue/PR number'),
|
number: z.number().describe('Issue/PR number'),
|
||||||
labels: z.array(z.union([z.number(), z.string()])).describe('Label IDs or names to set (use gitea_labels_list to discover available labels)'),
|
labels: z.array(z.number()).describe('Label IDs to set'),
|
||||||
...ConnectionParam,
|
...ConnectionParam,
|
||||||
},
|
},
|
||||||
async ({ owner, repo, number, labels, connection }) => formatResponse(await clientFor(connection).put(`/repos/${owner}/${repo}/issues/${number}/labels`, { labels })),
|
async ({ owner, repo, number, labels, connection }) => formatResponse(await clientFor(connection).put(`/repos/${owner}/${repo}/issues/${number}/labels`, { labels })),
|
||||||
@@ -1623,7 +1561,7 @@ server.tool(
|
|||||||
case 'POST': return formatResponse(await client.post(endpoint, body));
|
case 'POST': return formatResponse(await client.post(endpoint, body));
|
||||||
case 'PUT': return formatResponse(await client.put(endpoint, body));
|
case 'PUT': return formatResponse(await client.put(endpoint, body));
|
||||||
case 'PATCH': return formatResponse(await client.patch(endpoint, body));
|
case 'PATCH': return formatResponse(await client.patch(endpoint, body));
|
||||||
case 'DELETE': return formatResponse(await client.delete(endpoint, body));
|
case 'DELETE': return formatResponse(await client.delete(endpoint));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -1643,52 +1581,6 @@ server.tool(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// ── Metadata ────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_metadata_get',
|
|
||||||
'Get repo metadata (project identity, governance, distribution, build settings)',
|
|
||||||
{
|
|
||||||
owner: z.string().describe('Repository owner'),
|
|
||||||
repo: z.string().describe('Repository name'),
|
|
||||||
...ConnectionParam,
|
|
||||||
},
|
|
||||||
async ({ owner, repo, connection }) => {
|
|
||||||
const c = clientFor(connection);
|
|
||||||
return formatResponse(await c.get(`/repos/${owner}/${repo}/metadata`));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
server.tool(
|
|
||||||
'gitea_metadata_update',
|
|
||||||
'Update repo metadata settings (merges with existing — only provided fields are changed)',
|
|
||||||
{
|
|
||||||
owner: z.string().describe('Repository owner'),
|
|
||||||
repo: z.string().describe('Repository name'),
|
|
||||||
name: z.string().optional().describe('Project name'),
|
|
||||||
org: z.string().optional().describe('Organization'),
|
|
||||||
version: z.string().optional().describe('Version string (e.g. 06.00.00)'),
|
|
||||||
version_prefix: z.string().optional().describe('Tag prefix for version display (e.g. v1.26.1-moko.)'),
|
|
||||||
license_spdx: z.string().optional().describe('SPDX license identifier'),
|
|
||||||
platform: z.string().optional().describe('Platform (joomla, wordpress, dolibarr, go, mcp, platform, generic)'),
|
|
||||||
info_url: z.string().optional().describe('Extension info/product page URL'),
|
|
||||||
target_version: z.string().optional().describe('Target platform version regex (e.g. (5|6)\\.*)'),
|
|
||||||
php_minimum: z.string().optional().describe('Minimum PHP version (e.g. 8.1)'),
|
|
||||||
package_type: z.string().optional().describe('Extension type (component, module, plugin, package, template, library, file)'),
|
|
||||||
entry_point: z.string().optional().describe('Build entry point path'),
|
|
||||||
...ConnectionParam,
|
|
||||||
},
|
|
||||||
async ({ owner, repo, connection, ...fields }) => {
|
|
||||||
const c = clientFor(connection);
|
|
||||||
const current = await c.get(`/repos/${owner}/${repo}/metadata`);
|
|
||||||
const merged = { ...(current.data as Record<string, unknown>) };
|
|
||||||
for (const [k, v] of Object.entries(fields)) {
|
|
||||||
if (v !== undefined) merged[k] = v;
|
|
||||||
}
|
|
||||||
return formatResponse(await c.put(`/repos/${owner}/${repo}/metadata`, merged));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// ── Start Server ────────────────────────────────────────────────────────
|
// ── Start Server ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user