Skip to content

Commit 91f4616

Browse files
committed
Report content-length, shasum256, github-request
Output for `shasum256` should be compatible with `shasum -a 256`. When things go wrong, the x-github-request-id should be meaningful to https://support.github.com.
1 parent 6639677 commit 91f4616

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gh-program-downloader

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,25 @@ validate_file_length() {
109109
'
110110
}
111111

112+
shasum() {
113+
perl -e '
114+
use Digest::SHA qw($errmsg);
115+
my $mode = "b";
116+
my $alg = 256;
117+
my $file = shift;
118+
my $digest = eval { Digest::SHA->new($alg)->addfile($file, $mode) };
119+
if ($@) { warn "shasum: $file: $errmsg\n"; exit; }
120+
print $digest->hexdigest;
121+
' "$1"
122+
}
123+
112124
download_artifact() {
113125
temp_file=$(mktemp)
114126
headers_file=$(mktemp)
115127
curl -D "$headers_file" -H "$AUTHORIZATION_HEADER" -o "$temp_file" -q -s -L "$artifact"
116128
content_length=$(get_content_length "$headers_file")
129+
request_id=$(grep -i ^x-github-request-id: "$headers_file" | tail -1)
130+
echo "Downloaded $artifact - content-length: $content_length; shasum256: $(shasum "$temp_file"); $request_id"
117131
content_length="$content_length" artifact="$artifact" temp_file="$temp_file" validate_file_length
118132

119133
echo "url=$artifact" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)