فهرست منبع

fix: retry the updated checksums manifest instead of restoring the old one

After the signed archives are uploaded, the old checksums.txt no longer
describes them, so restoring it left the release inconsistent. Retry the
updated manifest instead and fail with a clear message if it never lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 23 ساعت پیش
والد
کامیت
ec9cbe54c9
2فایلهای تغییر یافته به همراه17 افزوده شده و 11 حذف شده
  1. 2 0
      docs/modules/dev/pages/signing.adoc
  2. 15 11
      var/release/publish-signed-assets.sh

+ 2 - 0
docs/modules/dev/pages/signing.adoc

@@ -17,6 +17,8 @@ Like Windows signing, this happens **after** the release is published, so a prob
 
 If `sign-macos` fails (for example an expired Apple agreement, a notary outage or a certificate problem), the release stays published without macOS assets. Fix the cause, then use **Re-run failed jobs** on that workflow run. The unsigned artifact must still be within its retention period.
 
+The signed files are uploaded before `checksums.txt`. If the `checksums.txt` upload still fails after retries, the job fails and the release holds the new files with an out-of-date manifest. A re-run recomputes the manifest from the release's current `checksums.txt` and uploads it again.
+
 `sign-windows` and `sign-macos` share a concurrency group, so they never update `checksums.txt` at the same time.
 
 ### Prerequisites

+ 15 - 11
var/release/publish-signed-assets.sh

@@ -43,7 +43,6 @@ for src in "$@"; do
 done
 
 checksums_path="${DIST_DIR}/${CHECKSUMS_NAME}"
-checksums_backup="${DIST_DIR}/${CHECKSUMS_NAME}.orig"
 if ! gh release download "${TAG}" --pattern "${CHECKSUMS_NAME}" --dir "${DIST_DIR}" --clobber; then
   echo "Failed to download ${CHECKSUMS_NAME} from release ${TAG}" >&2
   exit 1
@@ -52,7 +51,6 @@ if [[ ! -f "${checksums_path}" ]]; then
   echo "${CHECKSUMS_NAME} not found after download from release ${TAG}" >&2
   exit 1
 fi
-cp -f "${checksums_path}" "${checksums_backup}"
 
 update_checksum() {
   local file_name="${1}"
@@ -72,17 +70,23 @@ for name in "${names[@]}"; do
   upload_paths+=("${DIST_DIR}/${name}")
 done
 
-# Upload binaries first so a failed checksums upload can restore the previous file.
 # --clobber overwrites same-named assets (needed if the sign job is re-run).
 gh release upload "${TAG}" "${upload_paths[@]}" --clobber
 
-if ! gh release upload "${TAG}" "${checksums_path}" --clobber; then
-  echo "Failed to upload updated ${CHECKSUMS_NAME}; restoring previous asset" >&2
-  restore_dir="$(mktemp -d)"
-  cp -f "${checksums_backup}" "${restore_dir}/${CHECKSUMS_NAME}"
-  gh release upload "${TAG}" "${restore_dir}/${CHECKSUMS_NAME}" --clobber
-  rm -rf "${restore_dir}"
-  exit 1
-fi
+# The new archives are already on the release, so only the updated manifest
+# describes them. Retry it rather than restore the old one.
+checksums_attempts=3
+for attempt in $(seq 1 "${checksums_attempts}"); do
+  if gh release upload "${TAG}" "${checksums_path}" --clobber; then
+    break
+  fi
+  if [[ "${attempt}" -eq "${checksums_attempts}" ]]; then
+    echo "Failed to upload updated ${CHECKSUMS_NAME} after ${checksums_attempts} attempts." >&2
+    echo "Release ${TAG} now has signed ${names[*]} but a stale or missing ${CHECKSUMS_NAME}; re-run this job." >&2
+    exit 1
+  fi
+  echo "Upload of ${CHECKSUMS_NAME} failed (attempt ${attempt}/${checksums_attempts}); retrying" >&2
+  sleep $((attempt * 10))
+done
 
 echo "Uploaded signed ${names[*]} to release ${TAG}"