From d2efa527bcaace679b00f78774d1ac53943b0539 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 24 May 2026 04:04:25 -0500 Subject: [PATCH] fix(ci): replace Step 8b inline Python with release_body_update.php The inline Python PATCH caused SIGPIPE (exit 141) due to printf pipe fragility. Replace with the PHP CLI tool from moko-platform which handles changelog extraction, body assembly, and API PATCH natively. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) --- .mokogitea/workflows/auto-release.yml | 41 ++++----------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/.mokogitea/workflows/auto-release.yml b/.mokogitea/workflows/auto-release.yml index 613c6e9..5bb83fa 100644 --- a/.mokogitea/workflows/auto-release.yml +++ b/.mokogitea/workflows/auto-release.yml @@ -852,42 +852,13 @@ jobs: SHA256_TAR="" [ -f "/tmp/${TAR_NAME}" ] && SHA256_TAR=$(sha256sum "/tmp/${TAR_NAME}" | cut -d' ' -f1) - # Extract latest changelog entry (strip the ## header to avoid duplicate) - CHANGELOG="" - if [ -f "CHANGELOG.md" ]; then - CHANGELOG=$(sed -n "/^## \[*${VERSION}/,/^## \[*[0-9]/p" CHANGELOG.md | sed '$d' | sed '1d') - [ -z "$CHANGELOG" ] && CHANGELOG=$(sed -n '/^## /,/^## /p' CHANGELOG.md | sed '$d' | sed '1d' | head -30) - fi + # Build args for CLI tool + ARGS="--version ${VERSION} --release-tag ${RELEASE_TAG}" + ARGS="${ARGS} --token ${{ secrets.GA_TOKEN }} --api-base ${API_BASE}" + [ -n "$SHA256_ZIP" ] && ARGS="${ARGS} --zip-name ${ZIP_NAME} --zip-sha ${SHA256_ZIP}" + [ -n "$SHA256_TAR" ] && ARGS="${ARGS} --tar-name ${TAR_NAME} --tar-sha ${SHA256_TAR}" - # Build release body (single header, no duplicate from changelog) - BODY="## ${VERSION} ($(date +%Y-%m-%d))\n\n" - if [ -n "$CHANGELOG" ]; then - BODY="${BODY}${CHANGELOG}\n\n" - fi - BODY="${BODY}---\n\n### Checksums\n\n" - BODY="${BODY}| File | SHA-256 |\n|------|--------|\n" - [ -n "$SHA256_ZIP" ] && BODY="${BODY}| \`${ZIP_NAME}\` | \`${SHA256_ZIP}\` |\n" - [ -n "$SHA256_TAR" ] && BODY="${BODY}| \`${TAR_NAME}\` | \`${SHA256_TAR}\` |\n" - - # Get release ID and update body - RELEASE_ID=$(curl -sf -H "Authorization: token ${{ secrets.GA_TOKEN }}" \ - "${API_BASE}/releases/tags/${RELEASE_TAG}" 2>/dev/null | \ - python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null || true) - - if [ -n "$RELEASE_ID" ] && [ "$RELEASE_ID" != "None" ]; then - python3 -c " - import json, urllib.request - body = '''$(printf '%b' "$BODY")''' - data = json.dumps({'body': body}).encode() - req = urllib.request.Request( - '${API_BASE}/releases/${RELEASE_ID}', - data=data, - headers={'Authorization': 'token ${{ secrets.GA_TOKEN }}', 'Content-Type': 'application/json'}, - method='PATCH' - ) - urllib.request.urlopen(req) - " 2>/dev/null && echo "Release body updated with changelog + SHA" >> $GITHUB_STEP_SUMMARY - fi + php /tmp/moko-platform-api/cli/release_body_update.php ${ARGS} --output-summary # -- STEP 9: Mirror to GitHub (stable only) -------------------------------- - name: "Step 9: Mirror release to GitHub" -- 2.52.0