zig-overlay/update

48 lines
1.2 KiB
Text
Raw Normal View History

#!/usr/bin/env nix-shell
2023-01-17 10:49:17 -08:00
#! nix-shell -p curl jq python3Full -i sh
2022-08-22 17:54:16 -07:00
set -e
# Build our new sources.json
curl -s 'https://ziglang.org/download/index.json' | jq '
2022-10-31 21:20:31 -07:00
["aarch64-linux", "x86_64-linux", "aarch64-macos", "x86_64-macos", "aarch64-windows", "x86_64-windows"] as $targets |
def todarwin(x): x | gsub("macos"; "darwin");
def toentry(vsn; x):
[(vsn as $version |
.value |
to_entries[] |
select(.key as $key | any($targets[]; . == $key)) | {
(todarwin(.key)): {
"url": .value.tarball,
"sha256": .value.shasum,
"version": $version,
}
}
)] | add | first(values, {});
reduce to_entries[] as $entry ({}; . * (
$entry | {
(.key): (
if (.key != "master") then
toentry(.key; .value)
else {
"latest": toentry(.value.version; .value),
(.value.date): toentry(.value.version; .value),
} end
)
}
))
' > sources.new.json
# For debugging
# cat sources.new.json
# exit
# Copy the old file since jq can't modify in-place. This is also a backup.
cp sources.json sources.old.json
# Recursive merge
jq -s '.[0] * .[1]' sources.old.json sources.new.json > sources.json
2023-01-17 10:49:17 -08:00
# Verify new release signatures and compute the SHA-256 sum.
python verify_and_hash.py