Просмотр исходного кода

fix: rebuild an incomplete checksums.txt and document the no-digest recovery

A failed upload can leave checksums.txt as an empty "starter" asset. Only
download the manifest when it is fully uploaded, and rebuild it otherwise.
Document how to rebuild the manifest by hand when an asset has no digest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 22 часов назад
Родитель
Сommit
0b5287f3e9
2 измененных файлов с 18 добавлено и 5 удалено
  1. 12 1
      docs/modules/dev/pages/signing.adoc
  2. 6 4
      var/release/publish-signed-assets.sh

+ 12 - 1
docs/modules/dev/pages/signing.adoc

@@ -17,7 +17,18 @@ 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.
 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 updates the release's current `checksums.txt` and uploads it again. If the failed upload left the release with no `checksums.txt`, the re-run rebuilds it from the sha256 digests GitHub records for each release asset.
+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 updates the release's current `checksums.txt` and uploads it again. If the failed upload left the release with no `checksums.txt`, or an incomplete one, the re-run rebuilds it from the sha256 digests GitHub records for each release asset.
+
+If any release asset has no recorded digest, the rebuild stops and the re-run fails. Rebuild the manifest by hand from the release's own files, then re-run the job:
+
+[source,bash]
+----
+mkdir assets && cd assets
+gh release download <tag> --repo OliveTin/OliveTin --skip-existing
+rm -f checksums.txt
+sha256sum * > ../checksums.txt
+gh release upload <tag> ../checksums.txt --repo OliveTin/OliveTin --clobber
+----
 
 
 `sign-windows` and `sign-macos` share a concurrency group, so they never update `checksums.txt` at the same time.
 `sign-windows` and `sign-macos` share a concurrency group, so they never update `checksums.txt` at the same time.
 
 

+ 6 - 4
var/release/publish-signed-assets.sh

@@ -46,10 +46,10 @@ checksums_path="${DIST_DIR}/${CHECKSUMS_NAME}"
 
 
 # gh release upload --clobber deletes the old asset before uploading, so an
 # gh release upload --clobber deletes the old asset before uploading, so an
 # earlier run that failed to upload the manifest can leave the release without
 # earlier run that failed to upload the manifest can leave the release without
-# one. The manifest lists every other release asset, so it can be rebuilt from
+# one, or with an incomplete one. The manifest lists every other release asset, so it can be rebuilt from
 # the sha256 digests GitHub records for them.
 # the sha256 digests GitHub records for them.
 rebuild_checksums() {
 rebuild_checksums() {
-  echo "${CHECKSUMS_NAME} is missing from release ${TAG}; rebuilding it from release asset digests" >&2
+  echo "${CHECKSUMS_NAME} is missing or incomplete on release ${TAG}; rebuilding it from release asset digests" >&2
   local assets
   local assets
   assets="$(gh release view "${TAG}" --json assets \
   assets="$(gh release view "${TAG}" --json assets \
     --jq ".assets[] | select(.name != \"${CHECKSUMS_NAME}\") | \"\(.digest // \"none\") \(.name)\"")"
     --jq ".assets[] | select(.name != \"${CHECKSUMS_NAME}\") | \"\(.digest // \"none\") \(.name)\"")"
@@ -66,8 +66,10 @@ rebuild_checksums() {
   done <<< "${assets}"
   done <<< "${assets}"
 }
 }
 
 
-release_assets="$(gh release view "${TAG}" --json assets --jq '.assets[].name')"
-if grep -qxF "${CHECKSUMS_NAME}" <<< "${release_assets}"; then
+# A failed upload can leave an empty asset in the "starter" state; only an
+# "uploaded" manifest is complete enough to update.
+uploaded_assets="$(gh release view "${TAG}" --json assets --jq '.assets[] | select(.state == "uploaded") | .name')"
+if grep -qxF "${CHECKSUMS_NAME}" <<< "${uploaded_assets}"; then
   if ! gh release download "${TAG}" --pattern "${CHECKSUMS_NAME}" --dir "${DIST_DIR}" --clobber; then
   if ! gh release download "${TAG}" --pattern "${CHECKSUMS_NAME}" --dir "${DIST_DIR}" --clobber; then
     echo "Failed to download ${CHECKSUMS_NAME} from release ${TAG}" >&2
     echo "Failed to download ${CHECKSUMS_NAME} from release ${TAG}" >&2
     exit 1
     exit 1