fix: per-channel updates.xml targeting + release on all patches
Some checks failed
Repo Health / Access control (push) Successful in 1s
Auto-Update SHA Hash / Update SHA-256 Hash in updates.xml (release) Failing after 4s
Repo Health / Release configuration (push) Failing after 4s
Repo Health / Scripts governance (push) Successful in 4s
Repo Health / Repository health (push) Failing after 4s

- 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) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-04-21 12:09:11 -05:00
parent 500bb38162
commit 116127c760
2 changed files with 61 additions and 38 deletions

View File

@@ -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

View File

@@ -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)
export PY_DATE="$DATE"
# Update version
sed -i "s|<version>.*</version>|<version>${TAG}</version>|" updates.xml
python3 << 'PYEOF'
import re, os
# Update creation date
sed -i "s|<creationDate>.*</creationDate>|<creationDate>${DATE}</creationDate>|" updates.xml
tag = os.environ["PY_TAG"]
sha256 = os.environ["PY_SHA"]
date = os.environ["PY_DATE"]
stability = os.environ["PY_STABILITY"]
# Update download URL
sed -i "s|<downloadurl type='full' format='zip'>.*</downloadurl>|<downloadurl type='full' format='zip'>https://github.com/${{ github.repository }}/releases/download/${TAG}/mokocassiopeia-src-${TAG}.zip</downloadurl>|" updates.xml
with open("updates.xml") as f:
content = f.read()
# Update or add SHA-256 hash
if grep -q "<sha256>" updates.xml; then
sed -i "s|<sha256>.*</sha256>|<sha256>sha256:${SHA256}</sha256>|" updates.xml
else
# Add SHA-256 after downloadurl
sed -i "/<\/downloadurl>/a\ <sha256>sha256:${SHA256}<\/sha256>" updates.xml
fi
pattern = r"(<update>(?:(?!</update>).)*?<tag>" + re.escape(stability) + r"</tag>.*?</update>)"
match = re.search(pattern, content, re.DOTALL)
echo "Updated updates.xml with:"
echo " Version: ${TAG}"
echo " Date: ${DATE}"
echo " SHA-256: ${SHA256}"
if not match:
print(f"No <update> block for <tag>{stability}</tag> — skipping")
exit(0)
block = match.group(1)
original = block
block = re.sub(r"<sha256>[^<]*</sha256>", f"<sha256>{sha256}</sha256>", block)
block = re.sub(r"<creationDate>[^<]*</creationDate>", f"<creationDate>{date}</creationDate>", 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] <gitea-actions[bot]@mokoconsulting.tech>"
git push origin main