From c89a2f49793f587d18eb5e1117e3eb3d279b9844 Mon Sep 17 00:00:00 2001 From: t8y2 <1156263951@qq.com> Date: Fri, 11 Sep 2026 09:39:26 +0800 Subject: [PATCH] fix(ci): keep R2 updater manifest complete and self-healing Validate latest.json platform completeness before syncing to R2 and derive the R2 manifest from the GitHub release in sync-changelog. --- .github/workflows/publish-packages.yml | 20 ++++++++++++++++++++ .github/workflows/sync-changelog.yml | 12 +++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index c31586b755..906969a1c9 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -239,6 +239,26 @@ jobs: --clobber ls -lh assets/ + - name: Validate latest.json completeness + run: | + LATEST_JSON="assets/latest.json" + if [ ! -f "$LATEST_JSON" ]; then + echo "::error::latest.json not found in release assets; refusing to sync an incomplete manifest to R2" + exit 1 + fi + MISSING="" + for p in darwin-aarch64 darwin-x86_64 windows-x86_64 windows-aarch64 linux-x86_64 linux-aarch64; do + if ! jq -e --arg p "$p" '.platforms[$p] != null' "$LATEST_JSON" >/dev/null; then + MISSING="${MISSING} ${p}" + fi + done + if [ -n "$MISSING" ]; then + echo "::error::latest.json is missing updater platforms:${MISSING}. Release builds may still be uploading assets; dispatch again after all release jobs finish." + exit 1 + fi + echo "Platform manifest complete:" + jq -r '.platforms | keys[]' "$LATEST_JSON" + - name: Rewrite latest.json download URLs to R2 CDN run: | TAG="${{ steps.version.outputs.tag }}" diff --git a/.github/workflows/sync-changelog.yml b/.github/workflows/sync-changelog.yml index 3033a67ac4..10a995725e 100644 --- a/.github/workflows/sync-changelog.yml +++ b/.github/workflows/sync-changelog.yml @@ -97,9 +97,15 @@ jobs: --overwrite-existing ENDPOINT="https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com" - aws s3 cp "s3://${R2_BUCKET_NAME}/releases/latest/latest.json" r2-latest.json --endpoint-url "$ENDPOINT" - jq --arg notes "$NOTES" '.notes = $notes' r2-latest.json > r2-latest.json.tmp - mv r2-latest.json.tmp r2-latest.json + # Derive the R2 manifest from the GitHub release latest.json (notes already + # injected above) instead of re-reading the R2 copy, so every sync also + # heals a stale or partial R2 manifest. + jq --arg tag "$TAG" ' + (.platforms[]?.url?) |= ( + sub("https://github\\.com/t8y2/dbx/releases/download/" + $tag + "/"; "https://dl.dbxio.com/releases/latest/") + + "?v=" + $tag + ) + ' updater-assets/latest.json > r2-latest.json aws s3 cp r2-latest.json "s3://${R2_BUCKET_NAME}/releases/${TAG}/latest.json" \ --endpoint-url "$ENDPOINT" --content-type application/json --cache-control no-cache aws s3 cp r2-latest.json "s3://${R2_BUCKET_NAME}/releases/latest/latest.json" \