-
Notifications
You must be signed in to change notification settings - Fork 1
chore: windows scripts #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.