Skip to content

Commit

Permalink
fix: first try for supporting macOs, linux and windows in documented …
Browse files Browse the repository at this point in the history
…install script
  • Loading branch information
LMaxence committed Aug 23, 2024
1 parent 74daab0 commit 945e858
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
28 changes: 7 additions & 21 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,20 @@

=== "Linux"

``` c
#include <stdio.h>

int main(void) {
printf("Hello world!\n");
return 0;
}
``` bash title="Install Gookme"
curl -sSL https://raw.githubusercontent.com/LMaxence/gookme/main/scripts/install.sh | bash
```

=== "MacOS"

``` c++
#include <iostream>

int main(void) {
std::cout << "Hello world!" << std::endl;
return 0;
}
``` bash title="Install Gookme"
curl -sSL https://raw.githubusercontent.com/LMaxence/gookme/main/scripts/install.sh | bash
```
=== "Windows"

``` c++
#include <iostream>

int main(void) {
std::cout << "Hello world!" << std::endl;
return 0;
}
``` bash title="Install Gookme"
Invoke-WebRequest -Uri https://raw.githubusercontent.com/LMaxence/gookme/main/scripts/install.ps1 -OutFile install.ps1
.\install.ps1
```

## Configuration
Expand Down
2 changes: 1 addition & 1 deletion packages/meta/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package meta

const GOOKME_CLI_VERSION = "0.3.2"
const GOOKME_CLI_VERSION = "0.3.3"
34 changes: 34 additions & 0 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Define variables
$repoOwner = "LMaxence"
$repoName = "gookme"
$binaryName = "gookme"
$version = "latest"

# Determine the architecture
$arch = if ([System.Environment]::Is64BitOperatingSystem) { "amd64" } else { "arm64" }

# Construct the download URL
$url = "https://github.com/$repoOwner/$repoName/releases/$version/download/$binaryName-windows-$arch.exe"

# Define the destination path
$destinationPath = "$env:USERPROFILE\Downloads\$binaryName.exe"

# Download the binary
Write-Host "Downloading $binaryName from $url..."
Invoke-WebRequest -Uri $url -OutFile $destinationPath

# Make the binary executable (not necessary on Windows, but we'll move it to a PATH directory)
$installPath = "$env:ProgramFiles\$binaryName"
if (-Not (Test-Path -Path $installPath)) {
New-Item -ItemType Directory -Path $installPath
}
Move-Item -Path $destinationPath -Destination "$installPath\$binaryName.exe"

# Add the install path to the system PATH if not already present
$path = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
if ($path -notlike "*$installPath*") {
[System.Environment]::SetEnvironmentVariable("Path", "$path;$installPath", [System.EnvironmentVariableTarget]::Machine)
Write-Host "Added $installPath to the system PATH."
}

Write-Host "$binaryName installed successfully."
24 changes: 13 additions & 11 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ BINARY_NAME="gookme"

# Determine the OS and architecture
OS=$(uname | tr '[:upper:]' '[:lower:]')
# OS is darwin on MacOS and default to linux for all other OSes
if [ "$OS" == "darwin" ]; then
echo "Downloading Gookme for MacOS..."
OS="macos"
else
echo "Downloading Gookme for Linux..."
OS="linux"
fi

ARCH=$(uname -m)

# Map architecture names to the expected format
Expand All @@ -23,25 +32,18 @@ case $ARCH in
;;
esac

# Determine the file extension for Windows
EXT=""
if [ "$OS" = "mingw64_nt-10.0" ] || [ "$OS" = "msys_nt-10.0" ]; then
OS="windows"
EXT=".exe"
fi

# Construct the download URL for the latest release
URL="https://github.com/$REPO_OWNER/$REPO_NAME/releases/latest/download/$BINARY_NAME-$OS-$ARCH$EXT"
URL="https://github.com/$REPO_OWNER/$REPO_NAME/releases/latest/download/$BINARY_NAME-$OS-$ARCH"

# Download the binary
echo "Downloading $BINARY_NAME from $URL..."
curl -L -o "$BINARY_NAME$EXT" "$URL"
curl -L -o "$BINARY_NAME" "$URL"

# Make the binary executable
chmod +x "$BINARY_NAME$EXT"
chmod +x "$BINARY_NAME"

# Move the binary to a directory in the PATH
mv "$BINARY_NAME$EXT" "/usr/local/bin/$BINARY_NAME$EXT"
mv "$BINARY_NAME" "/usr/local/bin/$BINARY_NAME"

gookme --version
echo "Successfully installed Gookme."

0 comments on commit 945e858

Please sign in to comment.