Skip to content

Commit 4aac9c4

Browse files
pankgeorgmortenpi
andauthored
chore: windows scripts (#6)
* chore: windows scripts * fix install * feat: ./jh update * chore: apply suggestions from code review Co-authored-by: Morten Piibeleht <morten.piibeleht@gmail.com> --------- Co-authored-by: Morten Piibeleht <morten.piibeleht@gmail.com>
1 parent 5fe31cf commit 4aac9c4

File tree

6 files changed

+557
-6
lines changed

6 files changed

+557
-6
lines changed

README.md

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ A command-line interface for interacting with JuliaHub, a platform for Julia com
1313

1414
## Installation
1515

16-
### Quick Install (Recommended)
16+
### Quick Install
17+
18+
#### Linux and macOS
1719

1820
Install the latest release automatically:
1921

2022
```bash
21-
curl -sSfL https://raw.githubusercontent.com/JuliaComputing/jh/main/install.sh | bash
23+
curl -sSfL https://raw.githubusercontent.com/JuliaComputing/jh/main/install.sh | sh
2224
```
2325

2426
Or download and run the script manually:
@@ -35,9 +37,50 @@ chmod +x install.sh
3537

3638
**Custom installation directory example:**
3739
```bash
38-
curl -sSfL https://raw.githubusercontent.com/JuliaComputing/jh/main/install.sh | bash -s -- --install-dir /usr/local/bin
40+
curl -sSfL https://raw.githubusercontent.com/JuliaComputing/jh/main/install.sh | sh -s -- --install-dir /usr/local/bin
41+
```
42+
43+
#### Windows
44+
45+
**Option 1: PowerShell (Recommended)**
46+
47+
```powershell
48+
# Download and run the PowerShell installer
49+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/JuliaComputing/jh/main/install.ps1" -OutFile "install.ps1"; .\install.ps1; Remove-Item install.ps1
50+
```
51+
52+
Or download and run manually:
53+
```powershell
54+
# Download the installer
55+
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/JuliaComputing/jh/main/install.ps1" -OutFile "install.ps1"
56+
57+
# Run the installer
58+
.\install.ps1
59+
60+
# Clean up
61+
Remove-Item install.ps1
62+
63+
**Option 2: Command Prompt (CMD)**
64+
65+
```cmd
66+
curl -L "https://raw.githubusercontent.com/JuliaComputing/jh/main/install.bat" -o install.bat && install.bat && del install.bat
67+
```
68+
69+
Or download and run manually:
70+
```cmd
71+
curl -L "https://raw.githubusercontent.com/JuliaComputing/jh/main/install.bat" -o install.bat
72+
install.bat
73+
del install.bat
3974
```
4075

76+
**Windows Installation Notes:**
77+
- PowerShell script supports custom install directory: `.\install.ps1 -InstallDir "C:\tools\bin"`
78+
- PowerShell script can automatically add to PATH: will prompt unless you use `-NoPrompt`
79+
- For automated installs: `.\install.ps1 -NoPrompt` (won't add to PATH automatically)
80+
- Default install location: `%USERPROFILE%\.local\bin`
81+
- CMD script requires curl (available in Windows 10 1803+ and Windows 11)
82+
- After installation, restart your terminal or run `refreshenv` to use `jh` command
83+
4184
### Download Binary Manually
4285

4386
Download the latest release from the [GitHub releases page](https://github.com/JuliaComputing/jh/releases).
@@ -132,6 +175,11 @@ go build -o jh .
132175

133176
- `jh user info` - Show detailed user information
134177

178+
### Update (`jh update`)
179+
180+
- `jh update` - Check for updates and automatically install the latest version
181+
- `jh update --force` - Force update even if current version is newer than latest release
182+
135183
## Configuration
136184

137185
Configuration is stored in `~/.juliahub` with 0600 permissions. The file contains:

install.bat

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

0 commit comments

Comments
 (0)