From 116127c7606fae22e0582447ab1bfb39ce363dfa Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 21 Apr 2026 12:09:11 -0500 Subject: [PATCH] fix: per-channel updates.xml targeting + release on all patches - auto-update-sha: replace blanket sed with Python targeting only the matching stability channel, fix sha256: prefix to raw hex - auto-release: remove patch 00 skip, all patches now release Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/auto-release.yml | 20 +++---- .github/workflows/auto-update-sha.yml | 79 ++++++++++++++++++--------- 2 files changed, 61 insertions(+), 38 deletions(-) diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 8933815..87f13cf 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -26,7 +26,7 @@ # | 8. Build ZIP, upload asset, write SHA-256 to updates.xml | # | | # | Every version change: archives main -> version/XX.YY branch | -# | Patch 00 = development (no release). First release = patch 01. | +# | All patches release (including 00). Patch 00/01 = full pipeline. | # | First release only (patch == 01): | # | 7b. Create new GitHub Release | # | | @@ -100,19 +100,13 @@ jobs: echo "minor=$MINOR" >> "$GITHUB_OUTPUT" echo "major=$MAJOR" >> "$GITHUB_OUTPUT" echo "release_tag=v${MAJOR}" >> "$GITHUB_OUTPUT" - if [ "$PATCH" = "00" ]; then - echo "skip=true" >> "$GITHUB_OUTPUT" - echo "is_minor=false" >> "$GITHUB_OUTPUT" - echo "Version: $VERSION (patch 00 = development — skipping release)" + echo "skip=false" >> "$GITHUB_OUTPUT" + if [ "$PATCH" = "00" ] || [ "$PATCH" = "01" ]; then + echo "is_minor=true" >> "$GITHUB_OUTPUT" + echo "Version: $VERSION (first release for this minor — full pipeline)" else - echo "skip=false" >> "$GITHUB_OUTPUT" - if [ "$PATCH" = "01" ]; then - echo "is_minor=true" >> "$GITHUB_OUTPUT" - echo "Version: $VERSION (first release — full pipeline)" - else - echo "is_minor=false" >> "$GITHUB_OUTPUT" - echo "Version: $VERSION (patch — platform version + badges only)" - fi + echo "is_minor=false" >> "$GITHUB_OUTPUT" + echo "Version: $VERSION (patch — platform version + badges only)" fi - name: Check if already released diff --git a/.github/workflows/auto-update-sha.yml b/.github/workflows/auto-update-sha.yml index c264abf..d5ce534 100644 --- a/.github/workflows/auto-update-sha.yml +++ b/.github/workflows/auto-update-sha.yml @@ -70,33 +70,60 @@ jobs: echo "sha256=${SHA256_HASH}" >> $GITHUB_OUTPUT echo "SHA-256 Hash: ${SHA256_HASH}" - - name: Update updates.xml + - name: Determine stability channel + id: channel run: | TAG="${{ steps.tag.outputs.tag }}" - SHA256="${{ steps.sha.outputs.sha256 }}" + case "$TAG" in + development) STABILITY="development" ;; + alpha) STABILITY="alpha" ;; + beta) STABILITY="beta" ;; + release-candidate) STABILITY="rc" ;; + *) STABILITY="stable" ;; + esac + echo "stability=${STABILITY}" >> $GITHUB_OUTPUT + echo "Channel: ${STABILITY}" + + - name: Update updates.xml (targeted channel only) + env: + PY_TAG: ${{ steps.tag.outputs.tag }} + PY_SHA: ${{ steps.sha.outputs.sha256 }} + PY_STABILITY: ${{ steps.channel.outputs.stability }} + run: | DATE=$(date +%Y-%m-%d) - - # Update version - sed -i "s|.*|${TAG}|" updates.xml - - # Update creation date - sed -i "s|.*|${DATE}|" updates.xml - - # Update download URL - sed -i "s|.*|https://github.com/${{ github.repository }}/releases/download/${TAG}/mokocassiopeia-src-${TAG}.zip|" updates.xml - - # Update or add SHA-256 hash - if grep -q "" updates.xml; then - sed -i "s|.*|sha256:${SHA256}|" updates.xml - else - # Add SHA-256 after downloadurl - sed -i "/<\/downloadurl>/a\ sha256:${SHA256}<\/sha256>" updates.xml - fi - - echo "Updated updates.xml with:" - echo " Version: ${TAG}" - echo " Date: ${DATE}" - echo " SHA-256: ${SHA256}" + export PY_DATE="$DATE" + + python3 << 'PYEOF' + import re, os + + tag = os.environ["PY_TAG"] + sha256 = os.environ["PY_SHA"] + date = os.environ["PY_DATE"] + stability = os.environ["PY_STABILITY"] + + with open("updates.xml") as f: + content = f.read() + + pattern = r"((?:(?!).)*?" + re.escape(stability) + r".*?)" + match = re.search(pattern, content, re.DOTALL) + + if not match: + print(f"No block for {stability} — skipping") + exit(0) + + block = match.group(1) + original = block + + block = re.sub(r"[^<]*", f"{sha256}", block) + block = re.sub(r"[^<]*", f"{date}", block) + + content = content.replace(original, block) + + with open("updates.xml", "w") as f: + f.write(content) + + print(f"Updated {stability} channel: sha={sha256[:16]}..., date={date}") + PYEOF - name: Check for changes id: changes @@ -118,8 +145,10 @@ jobs: git config --local user.email "gitea-actions[bot]@mokoconsulting.tech" git config --local user.name "gitea-actions[bot]" + STABILITY="${{ steps.channel.outputs.stability }}" git add updates.xml - git commit -m "chore: Update SHA-256 hash for release ${TAG} - SHA: ${{ steps.sha.outputs.sha256 }}" + git commit -m "chore: update ${STABILITY} SHA-256 for ${TAG} [skip ci]" \ + --author="gitea-actions[bot] " git push origin main