Last active
September 22, 2023 23:12
-
-
Save AssortedFantasy/042d41e5c564fd875248673e76d95b58 to your computer and use it in GitHub Desktop.
Automatically update zig binary to zig x86_64 master.
This file contains 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
@ECHO OFF | |
REM Automatic Zig Download and Install Script | |
REM Add the variable (as a variable) %ZIGPATH% to user path for usage. | |
REM Requires jq to be installed. | |
SET zigurl=https://ziglang.org/download/index.json | |
SET zigjson=.\zigmaster.json | |
ECHO Fetching Zig Master .json | |
curl -o %zigjson% %zigurl% | |
jq -r .master."""x86_64-windows""".tarball %zigjson% >tempfile | |
SET /p updateurl=<tempfile | |
jq -r .master."""x86_64-windows""".shasum %zigjson% >tempfile | |
SET /p updatesha=<tempfile | |
ECHO FETCHING | |
ECHO URL: %updateurl% | |
ECHO SHA: %updatesha% | |
curl -OJ "%updateurl%" | |
FOR %%i IN (%updateurl:/= %) DO SET updatefile=%%i | |
SET updatefolder=%updatefile:~0,-4% | |
ECHO DOWNLOADED: %updatefile% | |
ECHO UNZIPPING | |
tar -xf "%updatefile%" | |
ECHO OLD ZIGPATH: %ZIGPATH% | |
SET oldzig=%ZIGPATH% | |
SET newzig="%CD%\%updatefolder%" | |
ECHO NEW ZIGPATH: %newzig% | |
SETX ZIGPATH %newzig% | |
ECHO Cleaning Up | |
ECHO Delete Old Zig Installation: | |
IF EXIST %oldzig% RMDIR /S %oldzig% | |
DEL "%updatefile%" | |
DEL %zigjson% | |
DEL tempfile | |
PAUSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note it doesn't check the currently installed version of Zig. It just downloads master always.