rewrite: rewrote as github actions runnable

This commit is contained in:
2026-05-05 19:02:03 +02:00
parent 28e6506d05
commit 0fbf1b0663
12 changed files with 225 additions and 540 deletions
+25 -69
View File
@@ -1,82 +1,38 @@
#!/usr/bin/env bash
# check-update.sh
# Polls the AUR RPC API for the latest webkit2gtk version.
# If a newer version is detected, runs build.sh then publish.sh directly.
# Called by entrypoint.sh on a loop — runs entirely inside the container.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
# Fetches the latest webkit2gtk version from the AUR and compares with latest Github release
# Outputs the AUR version to GITHUB_OUTPUT if a build should be triggered, otherwiste ouputs an empty string
# Paths
STATE_DIR="${ROOT_DIR}/state"
LAST_VERSION_FILE="${STATE_DIR}/last_version"
mkdir -p "${STATE_DIR}"
REPO="${GITHUB_REPOSITORY}"
# Logging
# Output goes to stdout so docker compose logs picks it up automatically.
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [check-update] $*"
}
echo "Fetching AUR version..."
AUR_VERSION=$(curl -s "https://aur.archlinux.org/rpc/v5/info/webkit2gtk" \
| jq -r ".results[0].Version" \
)
# Fetch latest AUR version
AUR_API_URL="https://aur.archlinux.org/rpc/v5/info/webkit2gtk"
log "Querying AUR for webkit2gtk"
response=$(curl -fsSL "${AUR_API_URL}")
aur_version=$(echo "${response}" | jq -r '.results[0].Version')
if [[ -z "${aur_version}" || "${aur_version}" == "null" ]]; then
log "ERROR: Failed to parse version from AUR response: ${response}"
if [ -z "$AUR_VERSION" ] || [ "$AUR_VERSION" = "null" ]; then
echo "ERROR: Could not fetch AUR version" >&2
exit 1
fi
log "AUR version: ${aur_version}"
echo "AUR version: $AUR_VERSION"
# Compare with last built version
last_version=""
if [[ -f "${LAST_VERSION_FILE}" ]]; then
last_version=$(cat "${LAST_VERSION_FILE}")
fi
echo "Fetching latest Github release..."
TAG=$(gh release list \
--repo "$REPO" \
--limit 1 \
--json tagName \
--jq '.[0].tagName // ""'
)
RELEASE_VERSION="${TAG#v}"
log "Last built version: ${last_version:-<none>}"
echo "Release version: ${RELEASE_VERSION:-"(none)"}"
if [[ "${aur_version}" == "${last_version}" ]]; then
log "Already up to date, nothing to do"
exit 0
fi
log "New version detected: ${aur_version} (was: ${last_version:-<none>}), starting build"
# Update the webkit2gtk AUR clone
WEBKIT2GTK_DIR="${ROOT_DIR}/webkit2gtk"
if [[ -d "${WEBKIT2GTK_DIR}/.git" ]]; then
log "Pulling latest PKGBUILD from AUR"
git -C "${WEBKIT2GTK_DIR}" pull --ff-only
if [ -z "$RELEASE_VERSION" ] || [ "$AUR_VERSION" != "$RELEASE_VERSION" ]; then
echo "Version mismatch or no release found, build required"
echo "trigger_version=$AUR_VERSION" >> "$GITHUB_OUTPUT"
else
log "Cloning webkit2gtk from AUR"
git clone https://aur.archlinux.org/webkit2gtk.git "${WEBKIT2GTK_DIR}"
fi
# Build
log "Running build"
if "${SCRIPT_DIR}/build.sh"; then
log "Build succeeded"
else
log "ERROR: Build failed, aborting"
exit 1
fi
# Publish
log "Running publish"
if "${SCRIPT_DIR}/publish.sh"; then
log "Publish succeeded"
else
log "ERROR: Publish failed, exit code: $?"
exit 1
fi
# Record new version
echo "${aur_version}" > "${LAST_VERSION_FILE}"
log "Updated last_version to ${aur_version}, done"
echo "Version match, no build required"
echo "trigger_version=" >> "$GITHUB_OUTPUT"
fi