Last active
June 18, 2023 09:11
-
-
Save nickcernis/9620203a6ffa087c0740a6a3b987b21e to your computer and use it in GitHub Desktop.
Zig install/upgrade script, latest from master
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
#!/bin/bash | |
# Updates zig to the latest master version using the official binary, | |
# no compilation required. | |
# | |
# - Edit the ARCHITECTURE string to match your system. | |
# - Requires jq. `brew install jq` (macOS) or get it at https://jqlang.github.io/jq/. | |
# - Put the script in the directory you want zig to be installed below, such as ~/zig/bin. | |
# - Then run: chmod +x update-zig.sh && ./update-zig.sh | |
# - Zig will live in a subfolder named zig-master-latest. | |
# - Add that dir to your path, for example: | |
# zsh: | |
# path+=('/Users/youruser/zig/bin/zig-master-latest') | |
# | |
# fish: | |
# fish_add_path /Users/youruser/zig/bin/zig-master-latest | |
# - Run ./update-zig.sh whenever you want to grab the latest master version. | |
# Change this to match your architecture and OS: | |
# - x86_64-macos | |
# - aarch64-macos | |
# - x86_64-linux | |
# - aarch64-linux | |
# - riscv64-linux | |
# - powerpc64le-linux | |
# - powerpc-linux | |
# - x86-linux | |
# - x86_64-windows | |
# - aarch64-windows | |
# - x86-windows | |
ARCHITECTURE="x86_64-macos" | |
json=$(curl -s https://ziglang.org/download/index.json) | |
url=$(echo "$json" | jq -r ".master.\"$ARCHITECTURE\".tarball") | |
expected_sha=$(echo "$json" | jq -r ".master.\"$ARCHITECTURE\".shasum") | |
curl -O "$url" | |
actual_sha=$(shasum -a 256 zig*.tar.xz | awk '{print $1}') | |
if [ "$expected_sha" != "$actual_sha" ]; then | |
echo "SHA checksum verification failed." | |
echo "Expected: $expected_sha" | |
echo "Actual: $actual_sha" | |
exit 1 | |
fi | |
if [ ! -d "zig-master-latest" ]; then | |
mkdir zig-master-latest | |
fi | |
tar -xf zig*.tar.xz -C zig-master-latest --strip-components=1 | |
rm zig*.tar.xz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment