42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
|
|
if [[ -n "${SKIP_RELEASE:-}" ]]; then
|
|
echo "⚙️ SKIP_RELEASE set — skipping automated release build."
|
|
exit 0
|
|
fi
|
|
|
|
should_release=false
|
|
while read -r local_ref local_sha remote_ref remote_sha; do
|
|
[[ -z "${local_ref:-}" ]] && continue
|
|
if [[ "$local_ref" == "refs/heads/master" || "$remote_ref" == "refs/heads/master" ]]; then
|
|
should_release=true
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [[ "$should_release" != true ]]; then
|
|
exit 0
|
|
fi
|
|
|
|
echo "🚀 Pre-push hook detected master — running release build..."
|
|
"$ROOT_DIR/scripts/build_release.sh"
|
|
|
|
APPCAST_PATH="$ROOT_DIR/Sparkle/appcast.xml"
|
|
if ! git -C "$ROOT_DIR" diff --quiet "$APPCAST_PATH"; then
|
|
git -C "$ROOT_DIR" add "$APPCAST_PATH"
|
|
VERSION="$(python3 - "$ROOT_DIR/version.json" <<'PY'
|
|
import json, sys
|
|
with open(sys.argv[1], "r", encoding="utf-8") as handle:
|
|
data = json.load(handle)
|
|
print(data.get("marketing_version", "dev"))
|
|
PY
|
|
)"
|
|
git -C "$ROOT_DIR" commit -m "chore: update Sparkle appcast for ${VERSION}" >/dev/null
|
|
echo "📝 Committed updated Sparkle appcast for ${VERSION}."
|
|
fi
|
|
|
|
echo "✅ Release build complete — continuing push."
|