chore: more work on install scripts

This commit is contained in:
Slug-Boi
2024-12-01 20:52:20 +01:00
parent 3862338350
commit 73c9adf908
3 changed files with 44 additions and 7 deletions
+6 -7
View File
@@ -24,7 +24,8 @@ func main() {
if err != nil { if err != nil {
download() download()
} else { } else {
update() download()
//update()
} }
} }
@@ -40,26 +41,24 @@ func download() {
var cmd *exec.Cmd var cmd *exec.Cmd
// Download the latest release // Download the latest release
filename := "cocommit.tar.gz"
switch runtime.GOOS { switch runtime.GOOS {
case "darwin": case "darwin":
fmt.Println("Downloading mac version") fmt.Println("Downloading mac version")
filename := ""
if runtime.GOARCH == "amd64" { if runtime.GOARCH == "amd64" {
resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-darwin-x86_64.tar.gz") resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-darwin-x86_64.tar.gz")
filename = "cocommit-darwin-x86_64.tar.gz"
} else { } else {
resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-darwin-aarch64.tar.gz") resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-darwin-aarch64.tar.gz")
filename = "cocommit-darwin-aarch64.tar.gz"
} }
cmd = exec.Command("tar", "-xvf", filename) cmd = exec.Command("tar", "-xvf", filename)
case "windows": case "windows":
fmt.Println("Downloading windows version") fmt.Println("Downloading windows version")
resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-win.tar.gz") resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-win.tar.gz")
cmd = exec.Command("tar", "-xvf", "cocommit-win.tar.gz") cmd = exec.Command("tar", "-xvf", filename)
default: default:
fmt.Println("Downloading linux version") fmt.Println("Downloading linux version")
resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-linux.tar.gz") resp, err = http.Get("https://github.com/Slug-Boi/cocommit/releases/latest/download/cocommit-linux.tar.gz")
cmd = exec.Command("tar", "-xvf", "cocommit-linux.tar.gz") cmd = exec.Command("tar", "-xvf", filename)
} }
if err != nil { if err != nil {
fmt.Println("Error downloading file") fmt.Println("Error downloading file")
@@ -83,7 +82,7 @@ func download() {
// Extract the file // Extract the file
err = cmd.Run() err = cmd.Run()
if err != nil { if err != nil {
fmt.Println("Error extracting file") panic("Error extracting file")
} }
regExp := regexp.MustCompile("cocommit-.+") regExp := regexp.MustCompile("cocommit-.+")
+8
View File
@@ -0,0 +1,8 @@
$binaryUrl = "https://github.com/Slug-Boi/cocommit/blob/main/installer/bin/install-win"
$outputPath = "install-win.exe"
# Download the binary
Invoke-WebRequest -Uri $binaryUrl -OutFile $outputPath
# Run the binary
& .\$outputPath
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Determine the OS and architecture
OS=$(uname -s)
ARCH=$(uname -m)
file=""
url="https://github.com/Slug-Boi/cocommit/raw/refs/heads/chore_install_script/installer/bin/"
# Set the download URL based on the OS and architecture
if [ "$OS" == "Linux" ]; then
URL="${url}install-linux"
file="install-linux"
elif [ "$OS" == "Darwin" ]; then
if [ "$ARCH" == "x86_64" ]; then
URL="${url}install-darwin-x86_64"
file="install-darwin-x86_64"
else
URL="${url}install-darwin-aarch64"
file="install-darwin-aarch64"
fi
else
echo "Unsupported OS: $OS"
exit 1
fi
# Download and run the script
echo $file
curl -LJO $URL && chmod +x $file && ./$file