Merge pull request #48 from Slug-Boi/chore_install_script

This commit is contained in:
Theis
2024-12-01 22:33:49 +01:00
committed by GitHub
3 changed files with 143 additions and 1 deletions
+13 -1
View File
@@ -14,13 +14,25 @@
## Install:
### Install Script
The repo contains two different install scripts for unix based system and window. You can copy paste one of the commands below to use it.
**Unix:**
```
$ curl -L -o install.sh https://github.com/Slug-Boi/cocommit/raw/refs/heads/main/installer/install.sh && chmod +x install.sh && ./install.sh
```
**Windows:**
*The windows script is untested so please let me know if it works and use at your own risk*
```
$ Invoke-WebRequest -Uri https://github.com/Slug-Boi/cocommit/raw/refs/heads/main/installer/install.ps1 -OutFile install.ps1; .\install.ps1
```
### Go Install
It should be possible to install the program using the go install command:
```
$ go install github.com/Slug-Boi/cocommit
```
You will more than likely have to add the binary to your PATH after the fact if your go bin directory is not in your PATH already. Or you can create an alias to it using the instructions below.
### Manual Binary Install
Download the binary for your OS on the [release page](https://github.com/Slug-Boi/cocommit/releases)
Once downloaded you need to create an alias for your shell guides found below:
[Bash Guide for alias](https://linuxize.com/post/how-to-create-bash-aliases/)
+63
View File
@@ -0,0 +1,63 @@
# Determine the OS and architecture
# Set up a cleanup function to be triggered upon script exit
function Cleanup {
Remove-Item -ErrorAction SilentlyContinue "cocommit.tar.gz"
Remove-Item -ErrorAction SilentlyContinue "author.txt"
if ($file) {
Remove-Item -ErrorAction SilentlyContinue $file
}
}
trap { Cleanup } EXIT
$OS = (Get-CimInstance Win32_OperatingSystem).Caption
$ARCH = (Get-CimInstance Win32_Processor).Architecture
$file = ""
$url = "https://github.com/Slug-Boi/cocommit/releases/latest/download/"
# Set the download URL based on the OS and architecture
if ($OS -match "Windows") {
$URL = "${url}cocommit-win.tar.gz"
$file = "cocommit.exe"
} else {
Write-Host "Unsupported OS: $OS"
exit 1
}
# Download and run the script
Invoke-WebRequest -Uri $URL -OutFile "cocommit.tar.gz"
if ($?) {
tar -xvzf "cocommit.tar.gz"
Remove-Item "cocommit.tar.gz"
Remove-Item "author.txt"
if ($file) {
& .\$file -v
if ($LASTEXITCODE -ne 0) {
Write-Host "Failed to extract the binary"
exit 1
}
}
} else {
Write-Host "Failed to download the file"
exit 1
}
# Move the binary to the specified directory
$target_dir = Read-Host "Enter the directory to move the binary to (default: C:\Program Files\cocommit)"
$target_dir = if ($target_dir) { $target_dir } else { "C:\Program Files\cocommit" }
if (-Not (Test-Path (Split-Path $target_dir))) {
Write-Host "Directory does not exist: $(Split-Path $target_dir)"
exit 1
}
Move-Item -Path $file -Destination $target_dir
if ($?) {
Write-Host "Binary moved to $target_dir successfully"
} else {
Write-Host "Failed to move the binary to $target_dir"
exit 1
}
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# Determine the OS and architecture
# Set up a cleanup function to be triggered upon script exit
__cleanup ()
{
rm "cocommit.tar.gz" 2>/dev/null
rm author.txt 2>/dev/null
if [ -n "$file" ]; then
rm $file 2>/dev/null
fi
}
trap __cleanup EXIT
OS=$(uname -s)
ARCH=$(uname -m)
file=""
url="https://github.com/Slug-Boi/cocommit/releases/latest/download/"
# Set the download URL based on the OS and architecture
if [ "$OS" == "Linux" ]; then
URL="${url}cocommit-linux.tar.gz"
file="cocommit-linux"
elif [ "$OS" == "Darwin" ]; then
if [ "$ARCH" == "x86_64" ]; then
URL="${url}cocommit-darwin-x86_64.tar.gz"
file="cocommit-darwin"
else
URL="${url}cocommit-darwin-aarch64.tar.gz"
file="cocommit-darwin-aarch64"
fi
else
echo "Unsupported OS: $OS"
exit 1
fi
# Download and run the script
curl -L -o cocommit.tar.gz $URL && \
tar -xvzf cocommit.tar.gz && \
rm cocommit.tar.gz && rm author.txt && \
chmod +x $file && ./$file -v
if [ $? -ne 0 ]; then
echo "Failed to extract the binary"
exit 1
fi
# Move the binary to the current directory
read -p "Enter the directory to move the binary to (default: /usr/local/bin/cocommit): " target_dir
target_dir=${target_dir:-/usr/local/bin/cocommit}
if [ ! -d "$(dirname "$target_dir")" ]; then
echo "Directory does not exist: $(dirname "$target_dir")"
exit 1
fi
mv $file "$target_dir"
if [ $? -ne 0 ]; then
echo "Failed to move the binary to $target_dir"
exit 1
fi
echo "Binary moved to $target_dir successfully"