-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.bat
More file actions
124 lines (103 loc) · 3.89 KB
/
install.bat
File metadata and controls
124 lines (103 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@echo off
setlocal enabledelayedexpansion
:: JuliaHub CLI (jh) installer script for Windows
:: This script downloads and installs the latest release of jh from GitHub
:: Configuration
set REPO_OWNER=JuliaComputing
set REPO_NAME=jh
set BINARY_NAME=jh
if "%INSTALL_DIR%"=="" set INSTALL_DIR=%USERPROFILE%\.local\bin
:: Create install directory if it doesn't exist
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
echo JuliaHub CLI (%BINARY_NAME%) Installer for Windows
echo ================================================
:: Check if curl is available (Windows 10 1803+ has curl built-in)
curl --version >nul 2>&1
if %errorlevel% neq 0 (
echo ERROR: curl is required but not found. Please install curl or use PowerShell.
echo You can install curl from: https://curl.se/download.html
echo Or use the PowerShell install script instead.
exit /b 1
)
echo INFO: Fetching latest release information...
:: Get latest version from GitHub API
for /f "tokens=*" %%i in ('curl -s "https://api.github.com/repos/%REPO_OWNER%/%REPO_NAME%/releases/latest" ^| findstr "tag_name" ^| for /f "tokens=2 delims=:," %%j in ('findstr "tag_name"') do @echo %%~j') do set VERSION=%%i
set VERSION=%VERSION:"=%
set VERSION=%VERSION: =%
if "%VERSION%"=="" (
echo ERROR: Failed to get latest version information
exit /b 1
)
echo INFO: Latest version: %VERSION%
:: Detect architecture
set ARCH=amd64
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" set ARCH=arm64
:: Construct download URL and filenames
set BINARY_FILE=%BINARY_NAME%-windows-%ARCH%.exe
set DOWNLOAD_URL=https://github.com/%REPO_OWNER%/%REPO_NAME%/releases/download/%VERSION%/%BINARY_FILE%
set TEMP_FILE=%INSTALL_DIR%\%BINARY_FILE%.tmp
set FINAL_FILE=%INSTALL_DIR%\%BINARY_NAME%.exe
echo INFO: Downloading %BINARY_NAME% %VERSION% for windows-%ARCH%...
echo INFO: Download URL: %DOWNLOAD_URL%
:: Check if binary already exists
if exist "%FINAL_FILE%" (
echo INFO: Checking current installation...
for /f "tokens=*" %%i in ('"%FINAL_FILE%" --version 2^>nul') do set CURRENT_VERSION=%%i
if not "%CURRENT_VERSION%"=="" (
echo INFO: Current installation: !CURRENT_VERSION!
echo !CURRENT_VERSION! | findstr "%VERSION%" >nul
if !errorlevel! equ 0 (
echo INFO: Latest version is already installed
exit /b 0
)
)
echo WARNING: Existing installation found. It will be replaced.
)
:: Download binary
curl -L -o "%TEMP_FILE%" "%DOWNLOAD_URL%"
if %errorlevel% neq 0 (
echo ERROR: Failed to download binary from %DOWNLOAD_URL%
if exist "%TEMP_FILE%" del "%TEMP_FILE%"
exit /b 1
)
:: Verify download was successful
if not exist "%TEMP_FILE%" (
echo ERROR: Downloaded file not found
exit /b 1
)
:: Move to final location
move "%TEMP_FILE%" "%FINAL_FILE%" >nul
if %errorlevel% neq 0 (
echo ERROR: Failed to install binary to %FINAL_FILE%
exit /b 1
)
echo SUCCESS: Installed %BINARY_NAME% to %FINAL_FILE%
:: Check if install directory is in PATH
echo %PATH% | findstr /C:"%INSTALL_DIR%" >nul
if %errorlevel% neq 0 (
echo WARNING: %INSTALL_DIR% is not in your PATH.
echo To add it permanently, run:
echo setx PATH "%%PATH%%;%INSTALL_DIR%"
echo Or add it to your current session:
echo set PATH=%%PATH%%;%INSTALL_DIR%
echo.
)
:: Verify installation
if exist "%FINAL_FILE%" (
echo INFO: Verifying installation...
for /f "tokens=*" %%i in ('"%FINAL_FILE%" --version 2^>nul') do set VERSION_OUTPUT=%%i
if not "!VERSION_OUTPUT!"=="" (
echo SUCCESS: Installation verified: !VERSION_OUTPUT!
echo INFO: Run '%BINARY_NAME% --help' to get started
) else (
echo WARNING: Binary installed but version check failed
)
) else (
echo ERROR: Installation failed: binary not found
exit /b 1
)
echo.
echo SUCCESS: Installation complete!
echo INFO: You can now use '%BINARY_NAME%' to interact with JuliaHub
echo INFO: Start with: %BINARY_NAME% auth login
endlocal