From b1ef5ba837bc9f536267792d8f60664d7dceaba1 Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 1 Oct 2024 17:58:41 -0500 Subject: [PATCH] Update run script --- run.sh | 59 +++++++++++++++++++--------------------------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/run.sh b/run.sh index 983c36d..4c83da8 100755 --- a/run.sh +++ b/run.sh @@ -1,31 +1,16 @@ -#!/bin/bash +#!/bin/sh -# Determine the platform -OS=$(uname) -ARCH=$(uname -m) +set -e -# Set the download URL based on the platform -if [[ "$OS" == "Linux" ]]; then - if [[ "$ARCH" == "x86_64" ]]; then - PLATFORM="linux-amd64" - elif [[ "$ARCH" == "aarch64" ]]; then - PLATFORM="linux-arm64" - else - echo "Unsupported architecture: $ARCH" - exit 1 - fi -elif [[ "$OS" == "Darwin" ]]; then - if [[ "$ARCH" == "x86_64" ]]; then - PLATFORM="darwin-amd64" - elif [[ "$ARCH" == "arm64" ]]; then - PLATFORM="darwin-arm64" - else - echo "Unsupported architecture: $ARCH" - exit 1 - fi +if [ "$OS" = "Windows_NT" ]; then + target="x86_64-pc-windows-msvc" else - echo "Unsupported OS: $OS" - exit 1 + case $(uname -sm) in + "Darwin x86_64") target="x86_64-apple-darwin" ;; + "Darwin arm64") target="aarch64-apple-darwin" ;; + "Linux aarch64") target="aarch64-unknown-linux-gnu" ;; + *) target="x86_64-unknown-linux-musl" ;; + esac fi # Fetch the latest release download URL @@ -33,20 +18,14 @@ REPO="Xevion/spotify-player-quickauth" API_URL="https://api.github.com/repos/$REPO/releases/latest" DOWNLOAD_URL=$(curl -s $API_URL | grep "browser_download_url.*$PLATFORM" | cut -d '"' -f 4) -if [[ -z "$DOWNLOAD_URL" ]]; then - echo "Failed to find a download URL for platform: $PLATFORM" - exit 1 +if [ -z "$DOWNLOAD_URL" ]; then + echo "No release could be found for the current platform" + exit 1 fi -# # Download the executable -# EXECUTABLE="spotify-player-quickauth" -# curl -L -o $EXECUTABLE $DOWNLOAD_URL - -# # Make the executable runnable -# chmod +x $EXECUTABLE - -# # Run the executable -# ./$EXECUTABLE - -# # Delete the executable -# rm $EXECUTABLE \ No newline at end of file +# Download the executable +EXECUTABLE="spotify-player-quickauth.tmp" +curl -L -o $EXECUTABLE $DOWNLOAD_URL +chmod +x $EXECUTABLE +./$EXECUTABLE +rm $EXECUTABLE \ No newline at end of file