feat(ci): deploy zuey beta releases (#40)

* feat(ci): deploy zuey beta releases

Add automatic zuey VPS deployment to the dev beta release workflow after prerelease assets are published. Publish beta checksums and make the host upgrade script tolerate beta asset naming and checksum fallback.

* fix(deploy): allow active beta release reruns

Treat an existing target release as success only when it is already the active release and still contains the expected binary and migrations. This keeps automated beta deploy reruns from failing after a prior successful deploy while preserving fail-closed behavior for stale or partial release directories.
This commit is contained in:
Duy /zuey/ authored and GitHub committed 2026-05-22 19:49:43 +07:00
1 parent 81d96ae014
commit faa195156e
5 files changed
+204 -14

No files matched your search

+77 -11
View File
@@ -113,25 +113,94 @@ if ! [[ "$RESOLVED_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-(beta|rc)\.[0-9]+)?$ ]]; th
fi
VERSION="${RESOLVED_TAG#v}"
ASSET="goclaw-${VERSION}-linux-amd64.tar.gz"
ASSET_URL="https://github.com/${REPO}/releases/download/${RESOLVED_TAG}/${ASSET}"
ASSET=""
ASSET_URL=""
CHECKSUM_URL="https://github.com/${REPO}/releases/download/${RESOLVED_TAG}/CHECKSUMS.sha256"
TARGET_DIR="${RELEASES_DIR}/${RESOLVED_TAG}"
log "requested=${REQUESTED_TAG} resolved=${RESOLVED_TAG} asset=${ASSET}"
download_release_asset() {
local candidate url
for candidate in "goclaw-${VERSION}-linux-amd64.tar.gz" "goclaw-${RESOLVED_TAG}-linux-amd64.tar.gz"; do
url="https://github.com/${REPO}/releases/download/${RESOLVED_TAG}/${candidate}"
log "downloading release asset candidate=${candidate}"
if curl -fsSL -o "$candidate" "$url"; then
ASSET="$candidate"
ASSET_URL="$url"
return 0
fi
rm -f "$candidate"
done
fail "linux amd64 release asset not found for ${RESOLVED_TAG}"
}
github_release_asset_digest() {
local asset_name="$1"
curl -fsSL "https://api.github.com/repos/${REPO}/releases/tags/${RESOLVED_TAG}" | python3 -c '
import json
import sys
name = sys.argv[1]
release = json.load(sys.stdin)
for asset in release.get("assets", []):
if asset.get("name") == name:
digest = asset.get("digest", "")
if digest.startswith("sha256:"):
print(digest.split(":", 1)[1])
raise SystemExit(0)
raise SystemExit(1)
' "$asset_name"
}
verify_release_asset() {
if curl -fsSLO "$CHECKSUM_URL"; then
if grep " ${ASSET}$\|${ASSET}$" CHECKSUMS.sha256 | sha256sum -c -; then
log "checksum verified via CHECKSUMS.sha256"
return 0
fi
log "checksum file did not verify ${ASSET}; falling back to release asset digest"
else
log "CHECKSUMS.sha256 unavailable; falling back to release asset digest"
fi
local expected actual
if ! expected="$(github_release_asset_digest "$ASSET")"; then
fail "missing sha256 digest for ${ASSET}"
fi
read -r actual _ < <(sha256sum "$ASSET")
if [ "$actual" != "$expected" ]; then
fail "release asset digest verification failed"
fi
log "checksum verified via GitHub release asset digest"
}
log "requested=${REQUESTED_TAG} resolved=${RESOLVED_TAG}"
target_release_is_active() {
[ -d "$TARGET_DIR" ] || return 1
[ -L "${BASE_DIR}/current" ] || return 1
[ "$(readlink -f "${BASE_DIR}/current")" = "$(readlink -f "$TARGET_DIR")" ]
}
if [ "$DRY_RUN" = "1" ]; then
TMP_DIR="$(mktemp -d)"
cleanup() { rm -rf "$TMP_DIR"; }
trap cleanup EXIT
cd "$TMP_DIR"
curl -fsSLO "$ASSET_URL"
curl -fsSLO "$CHECKSUM_URL"
grep " ${ASSET}$\|${ASSET}$" CHECKSUMS.sha256 | sha256sum -c -
download_release_asset
verify_release_asset
log "dry-run ok"
exit 0
fi
if target_release_is_active; then
if [ ! -x "$TARGET_DIR/goclaw" ] || [ ! -d "$TARGET_DIR/migrations" ]; then
fail "active release is missing goclaw binary or migrations directory"
fi
log "target release already active: ${RESOLVED_TAG}"
write_status "succeeded" "$REQUESTED_TAG" "$RESOLVED_TAG" ""
exit 0
fi
write_status "running" "$REQUESTED_TAG" "$RESOLVED_TAG" ""
TMP_DIR="$(mktemp -d)"
@@ -139,11 +208,8 @@ cleanup() { rm -rf "$TMP_DIR"; }
trap cleanup EXIT
cd "$TMP_DIR"
log "downloading release asset"
curl -fsSLO "$ASSET_URL"
curl -fsSLO "$CHECKSUM_URL"
grep " ${ASSET}$\|${ASSET}$" CHECKSUMS.sha256 | sha256sum -c - || fail "checksum verification failed"
download_release_asset
verify_release_asset
if [ -e "$TARGET_DIR" ]; then
fail "target release already exists: $TARGET_DIR"