-
-
Save kassane/f593a6baf594be376a9f365d7132e084 to your computer and use it in GitHub Desktop.
Download Zig latest version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
cd /tmp | |
echo "=================================================" | |
echo "Downloading new Zig version:" | |
curl -s https://ziglang.org/download/index.json \ | |
| jq ".master.\"$(uname -m)-$(uname | awk '{ print tolower($0) }')\"" \ | |
| jq -r .tarball \ | |
| wget -q --show-progress -i - | |
shasum=$(curl -s https://ziglang.org/download/index.json \ | |
| jq ".master.\"$(uname -m)-$(uname | awk '{ print tolower($0) }')\"" \ | |
| jq -r .shasum) | |
file=$(ls | grep '.tar.xz') | |
echo "Verify checksums:" | |
if ! echo $shasum $file | sha256sum --check --status ; then | |
echo "Failed checksum for zig tarball" | |
exit 1 | |
else | |
echo "Successful checksum for zig tarball" | |
fi | |
tar -xf $file | |
folder=$file | |
folder=${folder%.*} | |
folder=${folder%.*} | |
echo "Removing old Zig version" | |
rm $file | |
rm -fr ~/.local/lib/zig | |
rm -f ~/.local/bin/zig | |
rm -f ~/.local/share/Zig/langref.html | |
echo "Updating files..." | |
mkdir -p ~/.local/lib/zig | |
mv $folder/lib/* ~/.local/lib/zig | |
mv $folder/zig ~/.local/bin | |
mv $folder/docs/langref.html ~/.local/share/Zig | |
echo "Removing download folder" | |
rm -fr $folder | |
echo "============================================" | |
echo "Updated Zig to $folder" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment