Skip to content

Instantly share code, notes, and snippets.

@AssortedFantasy
Last active September 22, 2023 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AssortedFantasy/042d41e5c564fd875248673e76d95b58 to your computer and use it in GitHub Desktop.
Save AssortedFantasy/042d41e5c564fd875248673e76d95b58 to your computer and use it in GitHub Desktop.
Automatically update zig binary to zig x86_64 master.
@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
@AssortedFantasy
Copy link
Author

Note it doesn't check the currently installed version of Zig. It just downloads master always.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment