@@ -143,6 +143,38 @@ function get_tags()
143143 JSON. parse (String (read (tags_json_path)))
144144end
145145
146+ # #### --------------------------------------------------------------------------------------
147+ # #### Get ETag and Last-Modified, so we know if we need to re-download and re-checksum files
148+
149+ Base. @kwdef struct HeadInfo
150+ etag:: Union{String, Nothing}
151+ last_modified:: Union{String, Nothing}
152+ end
153+
154+ function get_new_headinfo_for_url (url:: URI )
155+ local response = nothing
156+ try
157+ response = HTTP. head (url)
158+ catch
159+ error (" Encountered error when making HEAD request to URL: $url " )
160+ end
161+ headers = Dict (HTTP. headers (response))
162+ etag = get (headers, " ETag" , " " )
163+ last_modified = get (headers, " Last-Modified" , " " )
164+ if isempty (strip (etag))
165+ @warn " Got empty new ETag for URL: $new_etag "
166+ etag = nothing
167+ end
168+ if isempty (strip (last_modified))
169+ @warn " Got empty new ETag for URL: $new_etag "
170+ last_modified = nothing
171+ end
172+ head_info = HeadInfo (; etag, last_modified)
173+ return head_info
174+ end
175+
176+ # #### --------------------------------------------------------------------------------------
177+
146178function main (out_path)
147179 tags = get_tags ()
148180 tag_versions = filter (x -> x != = nothing , [vnum_maybe (basename (t[" ref" ])) for t in tags])
@@ -241,6 +273,24 @@ function main(out_path)
241273 end
242274
243275 # Build up metadata about this file
276+ if endswith (filename, " .dmg" )
277+ kind = " archive"
278+ extension = " dmg"
279+ elseif endswith (filename, " .exe" )
280+ kind = " installer"
281+ extension = " exe"
282+ elseif endswith (filename, " .tar.gz" )
283+ kind = " archive"
284+ extension = " tar.gz"
285+ elseif endswith (filename, " .zip" )
286+ kind = " archive"
287+ extension = " zip"
288+ else
289+ error (" Unsupported file extension in filename: $(filename) " )
290+ end
291+
292+ headinfo = get_new_headinfo_for_url (url)
293+
244294 file_dict = Dict (
245295 " triplet" => triplet (platform),
246296 " os" => meta_os (platform),
@@ -260,6 +310,13 @@ function main(out_path)
260310 file_dict[" asc" ] = asc_signature
261311 end
262312
313+ if ! isnothing (headinfo. etag)
314+ file_dict[" etag" ] = headinfo. etag
315+ end
316+ if ! isnothing (headinfo. last_modified)
317+ file_dict[" last-modified" ] = headinfo. last_modified
318+ end
319+
263320 # Right now, all we have are archives, but let's be forward-thinking
264321 # and make this an array of dictionaries that is easy to extensibly match
265322 push! (meta[version][" files" ], file_dict)
0 commit comments