|
|
@@ -43,9 +43,37 @@ for src in "$@"; do
|
|
|
done
|
|
|
|
|
|
checksums_path="${DIST_DIR}/${CHECKSUMS_NAME}"
|
|
|
-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
|
|
|
+
|
|
|
+# 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
|
|
|
+# one. The manifest lists every other release asset, so it can be rebuilt from
|
|
|
+# the sha256 digests GitHub records for them.
|
|
|
+rebuild_checksums() {
|
|
|
+ echo "${CHECKSUMS_NAME} is missing from release ${TAG}; rebuilding it from release asset digests" >&2
|
|
|
+ local assets
|
|
|
+ assets="$(gh release view "${TAG}" --json assets \
|
|
|
+ --jq ".assets[] | select(.name != \"${CHECKSUMS_NAME}\") | \"\(.digest // \"none\") \(.name)\"")"
|
|
|
+
|
|
|
+ : > "${checksums_path}"
|
|
|
+ local digest name
|
|
|
+ while read -r digest name; do
|
|
|
+ [[ -n "${name}" ]] || continue
|
|
|
+ if [[ "${digest}" != sha256:* ]]; then
|
|
|
+ echo "Release asset ${name} has no sha256 digest; cannot rebuild ${CHECKSUMS_NAME}" >&2
|
|
|
+ exit 1
|
|
|
+ fi
|
|
|
+ printf '%s %s\n' "${digest#sha256:}" "${name}" >> "${checksums_path}"
|
|
|
+ done <<< "${assets}"
|
|
|
+}
|
|
|
+
|
|
|
+release_assets="$(gh release view "${TAG}" --json assets --jq '.assets[].name')"
|
|
|
+if grep -qxF "${CHECKSUMS_NAME}" <<< "${release_assets}"; then
|
|
|
+ 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
|
|
|
+ fi
|
|
|
+else
|
|
|
+ rebuild_checksums
|
|
|
fi
|
|
|
if [[ ! -f "${checksums_path}" ]]; then
|
|
|
echo "${CHECKSUMS_NAME} not found after download from release ${TAG}" >&2
|