Files
kawaiipunk 35326a0e33
CI / Validate scripts and pinned versions (push) Canceled after 0s
CI / Build Flatpak (push) Canceled after 0s
CI / Auto-merge update PR (push) Canceled after 0s
Add automated upstream update workflow
update-version.sh bumps the pinned Patchwork release: it fetches the latest
upstream tag, downloads both tar.gz assets, updates versions.sh, the manifest
and the metainfo, then self-validates with check-versions.sh. A daily cron
workflow commits the bump and opens a PR labeled automerge; the CI workflow
builds the Flatpak in the freedesktop-24.08 container and auto-merges the PR
once the checks pass.
2026-08-13 01:20:42 +02:00

108 lines
3.4 KiB
Bash
Executable File

#!/bin/bash
# Update the pinned Patchwork (Poncho Wonky) release to the latest upstream
# release, touching versions.sh, the manifest and the metainfo. Does not touch
# RUNTIME_VERSION (runtime bumps stay manual).
#
# Usage: ./update-version.sh [--dry-run]
set -euo pipefail
cd "$(dirname "$0")"
DRY_RUN=0
if [ "${1:-}" = "--dry-run" ]; then
DRY_RUN=1
fi
VERSIONS="versions.sh"
MANIFEST="nz.scuttlebutt.Patchwork.yaml"
METAINFO="nz.scuttlebutt.Patchwork.metainfo.xml"
UPSTREAM="soapdog/patchwork"
API="https://api.github.com/repos/${UPSTREAM}/releases/latest"
for cmd in curl jq; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "error: '$cmd' is required but not installed." >&2
exit 1
fi
done
source "$VERSIONS"
echo "Fetching latest release from ${UPSTREAM}..."
JSON=$(curl -fsSL "$API") || {
echo "error: failed to fetch ${API}" >&2
exit 1
}
TAG=$(printf '%s' "$JSON" | jq -r '.tag_name')
NEW_VERSION=${TAG#v}
NEW_DATE=$(printf '%s' "$JSON" | jq -r '.published_at' | cut -dT -f1)
X86_URL=$(printf '%s' "$JSON" | jq -r --arg n "ponchowonky-${NEW_VERSION}.tar.gz" \
'.assets[] | select(.name == $n) | .browser_download_url')
ARM_URL=$(printf '%s' "$JSON" | jq -r --arg n "ponchowonky-${NEW_VERSION}-arm64.tar.gz" \
'.assets[] | select(.name == $n) | .browser_download_url')
if [ -z "$X86_URL" ] || [ -z "$ARM_URL" ]; then
echo "error: could not find both tar.gz assets for ${TAG}." >&2
exit 1
fi
if [ "$NEW_VERSION" = "$APP_VERSION" ]; then
echo "Already up to date (${APP_VERSION})."
exit 0
fi
if [ "$(printf '%s\n%s\n' "$APP_VERSION" "$NEW_VERSION" | sort -V | head -1)" = "$NEW_VERSION" ]; then
echo "Latest upstream (${NEW_VERSION}) is not newer than current (${APP_VERSION}); nothing to do."
exit 0
fi
echo "New version: ${NEW_VERSION} (published ${NEW_DATE})"
if [ "$DRY_RUN" = 1 ]; then
echo "dry-run: would update ${APP_VERSION} -> ${NEW_VERSION}"
echo " x86_64: ${X86_URL}"
echo " aarch64: ${ARM_URL}"
exit 0
fi
OLD_VERSION=$APP_VERSION
OLD_X86_SHA=$APP_SHA256_X86_64
OLD_ARM_SHA=$APP_SHA256_AARCH64
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT
echo "Downloading x86_64 asset..."
curl -fsSL -o "$TMPDIR/x86_64.tar.gz" "$X86_URL"
echo "Downloading aarch64 asset..."
curl -fsSL -o "$TMPDIR/aarch64.tar.gz" "$ARM_URL"
X86_SHA=$(sha256sum "$TMPDIR/x86_64.tar.gz" | cut -d' ' -f1)
ARM_SHA=$(sha256sum "$TMPDIR/aarch64.tar.gz" | cut -d' ' -f1)
# Update manifest asset URLs (one pattern covers both the x86_64 and arm64 URLs).
sed -i "s|/v${OLD_VERSION}/ponchowonky-${OLD_VERSION}|/v${NEW_VERSION}/ponchowonky-${NEW_VERSION}|g" \
"$MANIFEST"
# Update manifest checksums.
sed -i "s|sha256: ${OLD_X86_SHA}|sha256: ${X86_SHA}|" "$MANIFEST"
sed -i "s|sha256: ${OLD_ARM_SHA}|sha256: ${ARM_SHA}|" "$MANIFEST"
# Update versions.sh.
sed -i "s|^export APP_VERSION=.*|export APP_VERSION=\"${NEW_VERSION}\"|" "$VERSIONS"
sed -i "s|^export APP_SHA256_X86_64=.*|export APP_SHA256_X86_64=\"${X86_SHA}\"|" "$VERSIONS"
sed -i "s|^export APP_SHA256_AARCH64=.*|export APP_SHA256_AARCH64=\"${ARM_SHA}\"|" "$VERSIONS"
# Insert a new <release> at the top of <releases> (AppStream requires newest-first).
sed -i "/^ <releases>$/a\\ <release version=\"${NEW_VERSION}\" date=\"${NEW_DATE}\"/>" \
"$METAINFO"
# Self-validate.
./check-versions.sh
echo
echo "Updated Patchwork to ${NEW_VERSION}."
echo " x86_64: ${X86_SHA}"
echo " aarch64: ${ARM_SHA}"
echo "Changed versions.sh, ${MANIFEST} and ${METAINFO}. Commit the changes."