From 5b00635279cd4648b0237b4b11ca8e2dfce4d7ac Mon Sep 17 00:00:00 2001 From: Jonathan Miller <1+jmiller@noreply.git.mokoconsulting.tech> Date: Tue, 14 Jul 2026 04:45:01 +0000 Subject: [PATCH] chore: sync auto-release.yml from Template-Joomla [skip ci] --- .mokogitea/workflows/auto-release.yml | 89 +++++---------------------- 1 file changed, 15 insertions(+), 74 deletions(-) diff --git a/.mokogitea/workflows/auto-release.yml b/.mokogitea/workflows/auto-release.yml index ee87c563..ce7bc6c7 100644 --- a/.mokogitea/workflows/auto-release.yml +++ b/.mokogitea/workflows/auto-release.yml @@ -5,16 +5,16 @@ # FILE INFORMATION # DEFGROUP: MokoGitea.Workflow # INGROUP: MokoCLI.Release -# REPO: https://git.mokoconsulting.tech/MokoConsulting/Template-Generic -# PATH: /.mokogitea/workflows/auto-release.yml +# REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli +# PATH: /templates/workflows/universal/auto-release.yml.template # VERSION: 05.01.00 -# BRIEF: Universal build & release � detects platform from metadata API +# BRIEF: Universal build & release � detects platform from MokoGitea repo metadata (API) # # +=======================================================================+ # | UNIVERSAL BUILD & RELEASE PIPELINE | # +=======================================================================+ # | | -# | Reads metadata API (joomla|dolibarr|generic) to branch logic. | +# | Reads MokoGitea repo metadata (joomla|dolibarr|generic) to branch logic. | # | | # | Platform-specific: | # | joomla: XML manifest, type-prefixed packages | @@ -104,36 +104,11 @@ jobs: - name: Rename branch to rc run: | - API_BASE="${MOKOGITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}" - AUTH="Authorization: token ${{ secrets.MOKOGITEA_TOKEN }}" - FROM="${{ github.event.pull_request.head.ref || 'dev' }}" - PR="${{ github.event.pull_request.number }}" - - # Resolve the source branch HEAD commit. - SRC_JSON=$(curl -sf -H "$AUTH" "${API_BASE}/branches/${FROM}") \ - || { echo "::error::Source branch ${FROM} not found"; exit 1; } - SRC_SHA=$(printf '%s' "$SRC_JSON" | python3 -c "import sys, json; print(json.load(sys.stdin)['commit']['id'])" 2>/dev/null || true) - [ -n "$SRC_SHA" ] || { echo "::error::Could not resolve HEAD of ${FROM}"; exit 1; } - - # Point rc at the source commit via git push. Gitea's git/refs PATCH API - # returns HTTP 405 on ANY protected branch (force or not, even for a user in - # the force-push allowlist), so it cannot move a protected rc. git push honors - # the push + force-push allowlists and creates rc if it is absent. - PUSH_URL="https://x-access-token:${{ secrets.MOKOGITEA_TOKEN }}@${MOKOGITEA_URL#https://}/${GITEA_ORG}/${GITEA_REPO}.git" - git config --global user.name "mokogitea-actions[bot]" - git config --global user.email "actions@mokoconsulting.tech" - git fetch --no-tags "$PUSH_URL" "${FROM}" - git push --force "$PUSH_URL" "FETCH_HEAD:refs/heads/rc" \ - || { echo "::error::Failed to point rc at ${FROM} (${SRC_SHA}) via git push"; exit 1; } - echo "rc set to ${FROM} (${SRC_SHA})" - - # Repoint the PR at rc, then delete the old source branch (non-fatal). - if [ -n "$PR" ]; then - curl -s -X PATCH -H "$AUTH" -H "Content-Type: application/json" \ - "${API_BASE}/pulls/${PR}" -d '{"head":"rc"}' >/dev/null || true - fi - curl -s -X DELETE -H "$AUTH" "${API_BASE}/branches/${FROM}" >/dev/null || true - echo "Renamed ${FROM} -> rc" + php ${MOKO_CLI}/branch_rename.php \ + --from "${{ github.event.pull_request.head.ref || 'dev' }}" --to rc \ + --token "${{ secrets.MOKOGITEA_TOKEN }}" \ + --api-base "${MOKOGITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}" \ + --pr "${{ github.event.pull_request.number }}" - name: Checkout rc and configure git run: | @@ -374,47 +349,13 @@ jobs: if [ -n "$VERSION" ] && [ -f "CHANGELOG.md" ]; then DATE=$(date +%Y-%m-%d) python3 -c " - import sys, re + import sys version, date = sys.argv[1], sys.argv[2] - lines = open('CHANGELOG.md').read().split('\n') - h2 = re.compile(r'^##\s+\[([^\]]+)\]') - header, sections, cur = [], [], None - for ln in lines: - m = h2.match(ln) - if m: - if cur: sections.append(cur) - cur = {'label': m.group(1).strip(), 'head': ln, 'body': []} - elif cur is None: - header.append(ln) - else: - cur['body'].append(ln) - if cur: sections.append(cur) - def nonempty(b): return any(x.strip() for x in b) - def trim(b): - b = b[:] - while b and not b[0].strip(): b.pop(0) - while b and not b[-1].strip(): b.pop() - return b - unreleased, order, bykey = [], [], {} - for s in sections: - key = s['label'].lower() - if key == 'unreleased': - if nonempty(s['body']): unreleased += s['body'] - continue - if not nonempty(s['body']): continue # drop blank release sections - if key in bykey: bykey[key]['body'] += [''] + s['body'] # merge duplicate heading (never drop content) - else: bykey[key] = s; order.append(key) - rest, seen = [bykey[k] for k in order], set(order) - out = [] - htxt = '\n'.join(header).rstrip() - if htxt: out += [htxt, ''] - out += ['## [Unreleased]', ''] - promote = bool(unreleased) and version.lower() not in seen - if unreleased and not promote: out += trim(unreleased) + [''] - if promote: out += ['## [%s] --- %s' % (version, date), ''] + trim(unreleased) + [''] - for s in rest: out += [s['head'], ''] + trim(s['body']) + [''] - res = re.sub(r'\n{3,}', '\n\n', '\n'.join(out)).rstrip('\n') + '\n' - open('CHANGELOG.md', 'w').write(res) + content = open('CHANGELOG.md').read() + old = '## [Unreleased]' + new = f'## [Unreleased]\n\n## [{version}] --- {date}' + content = content.replace(old, new, 1) + open('CHANGELOG.md', 'w').write(content) " "$VERSION" "$DATE" git add CHANGELOG.md git commit -m "chore: promote changelog [Unreleased] → [${VERSION}]" || true