#!/bin/bash # Set the GitHub repository REPO="navidrome/navidrome" # Set the platform #This is how it finds what release to grab. #It should be part of the file name you want under Assests on the release page. SEARCH=linux_amd64 # Fetch the latest release information using the GitHub API RELEASE_INFO=$(curl -s "https://api.github.com/repos/$REPO/releases/latest") # Extract the version using jq and store it in version.txt NEW_VERSION=$(echo "$RELEASE_INFO" | jq -r ".tag_name" | sed 's/[^0-9]*//g') CURRENT_VERSION=$(cat version.txt 2>/dev/null) # Check if version.txt exists and if the latest version is newer if [ -z "$CURRENT_VERSION" ] || [ "$NEW_VERSION" -gt "$CURRENT_VERSION" ]; then echo "Newer version available. Updating version.txt and downloading..." # Update version.txt with the new version echo "$NEW_VERSION" > version.txt # Extract the download URLs for all assets DOWNLOAD_URLS=$(echo "$RELEASE_INFO" | jq -r '.assets[] | .browser_download_url') # Loop through each download URL and find the one containing the SEARCH string for URL in $DOWNLOAD_URLS; do if [[ $URL == *"$SEARCH"* ]]; then DOWNLOAD_URL=$URL break fi done # Download the release if [ -n "$DOWNLOAD_URL" ]; then echo "Downloading $DOWNLOAD_URL" curl -LOs "$DOWNLOAD_URL" echo "Download complete." # Check if a tar file exists in the directory #Change file extension as needed! if [ -e *.tar.gz ]; then # Extract the tar file echo "Extracting tar file..." tar -zxvf *.tar.gz # Delete the tar file echo "Deleting tar file..." rm -f *.tar.gz echo "Tar file deleted." else echo "Error: No tar file found in the directory." exit 1 fi else echo "Error: Unable to find download URL for $SEARCH." exit 1 fi else echo "Already up-to-date. No need to download." fi exit