Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,31 @@ jobs:
return 1
}

# stapler validate also queries Apple's CloudKit for the ticket and
# hits the same transient -1005 disconnects.
validate_with_retry() {
local target="$1"
for attempt in 1 2 3 4 5; do
if xcrun stapler validate "$target"; then
return 0
fi
echo "validate attempt $attempt for $target failed, retrying in 10s..."
sleep 10
done
return 1
Comment on lines +329 to +332

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maintainability · low
最后一次(第 5 次)尝试失败后仍会打印 "retrying..." 并无意义地 sleep 10 秒才退出,日志具有误导性且浪费时间。建议仅在非最后一次尝试时才 sleep,或改为 while 循环在成功间隙重试。同样的问题也存在于上方的 staple_with_retry(属既有代码,可一并修复)。

Suggestion:

Suggested change
echo "validate attempt $attempt for $target failed, retrying in 10s..."
sleep 10
done
return 1
if [ "$attempt" -lt 5 ]; then
echo "validate attempt $attempt for $target failed, retrying in 10s..."
sleep 10
fi
done
return 1

}

echo "Stapling notarization ticket to app..."
if ! staple_with_retry "$APP_PATH"; then
echo "##[error]stapler staple failed for app after 5 attempts"
exit 1
fi

echo "Verifying notarization..."
xcrun stapler validate "$APP_PATH"
if ! validate_with_retry "$APP_PATH"; then
echo "##[error]stapler validate failed for app after 5 attempts"
exit 1
fi
spctl --assess --type execute --verbose "$APP_PATH"

echo "Notarization complete."
Expand Down
Loading