diff --git a/README.md b/README.md index 7df7944..f240d05 100644 --- a/README.md +++ b/README.md @@ -47,13 +47,25 @@ module load Pmodules/1.0.0 ./build 1.1.10 -f ``` -As descripted in the buildblock README, the +As described in the buildblock README, the [GUI](https://git.psi.ch/MELANIE/rollout/-/tree/master/Software/00-General/SciCatArchiverGUI) needs to be compiled separately and manually copied to AFS. -### Manual deployment +### Manual deployment and upgrade -Some machines need the tools deployed manually. This can be done as follows: +This can be followed to deploy or upgrade the tool manually: + +1. Go to the GitHub [releases page](https://github.com/paulscherrerinstitute/scicat-cli/releases). + +2. Choose the release of interest (`latest` is recommended) + +3. Download the file from the `Assets` of the chosen release, making sure to select the one compatible with your OS + +4. Decompress the asset + +5. Open the folder and run the required APP (grant `execute` permissions if required) + +#### One liner for Linux systems ```bash curl -s 'https://api.github.com/repos/paulscherrerinstitute/scicat-cli/releases/latest' \ diff --git a/datasetUtils/checkForNewVersion.go b/datasetUtils/checkForNewVersion.go index 57a39f7..b10cd32 100644 --- a/datasetUtils/checkForNewVersion.go +++ b/datasetUtils/checkForNewVersion.go @@ -7,7 +7,6 @@ import ( "log" "net/http" "os" - "runtime" "strconv" "strings" version "github.com/mcuadros/go-version" @@ -17,7 +16,7 @@ var scanner = bufio.NewScanner(os.Stdin) var ( GitHubAPI = "https://api.github.com/repos/paulscherrerinstitute/scicat-cli/releases/latest" - DeployLocation = "https://github.com/paulscherrerinstitute/scicat-cli/releases/download" + DonwloadInstructions = "https://github.com/paulscherrerinstitute/scicat-cli?tab=readme-ov-file#manual-deployment-and-upgrade" ) type Release struct { @@ -44,14 +43,6 @@ func fetchLatestVersion(client *http.Client) (string, error) { return strings.TrimSpace(release.TagName), nil } -// Make sure the version number is stripped of the 'v' prefix. That's required for `strconv.Atoi` to work. -func generateDownloadURL(deployLocation, latestVersion, osName string) string { - if strings.ToLower(osName) == "windows" { - return fmt.Sprintf("%s/v%s/scicat-cli_v%s_%s_x86_64.zip", deployLocation, latestVersion, latestVersion, strings.Title(osName)) - } - return fmt.Sprintf("%s/v%s/scicat-cli_v%s_%s_x86_64.tar.gz", deployLocation, latestVersion, latestVersion, strings.Title(osName)) -} - func CheckForNewVersion(client *http.Client, APP string, VERSION string) { // avoid checking for new version in test mode if os.Getenv("TEST_MODE") == "true" { @@ -74,26 +65,14 @@ func CheckForNewVersion(client *http.Client, APP string, VERSION string) { } log.Printf("Latest version: %s", latestVersion) - // Get the operating system name - osName := runtime.GOOS - - // Generate the download URL - downloadURL := generateDownloadURL(DeployLocation, latestVersion, osName) - - if version.Compare(latestVersion, VERSION, ">") { - // Notify an update if the version has changed - log.Println("You should upgrade to a newer version") - log.Println("Current Version: ", VERSION) - log.Println("Latest Version: ", latestVersion) - log.Println("You can either download the file using the browser or use the following command:") - - if strings.ToLower(osName) == "windows" { - log.Printf("Browser: %s\nCommand: curl -L -O %s; unzip scicat-cli_v%s_%s_x86_64.zip; cd scicat-cli\n", downloadURL, downloadURL, latestVersion, strings.Title(osName)) - } else { - log.Printf("Browser: %s\nCommand: curl -L -O %s; tar xzf scicat-cli_v%s_%s_x86_64.tar.gz; cd scicat-cli; chmod +x %s\n", downloadURL, downloadURL, latestVersion, strings.Title(osName), APP) - } - } else { + if !version.Compare(latestVersion, VERSION, ">") { log.Println("Your version of this program is up-to-date") + return } - return + + // Notify an update if the version has changed + log.Println("You should upgrade to a newer version") + log.Println("Current Version:", VERSION) + log.Println("Latest Version:", latestVersion) + log.Println("You can find the download instructions here:", DonwloadInstructions) } diff --git a/datasetUtils/checkForNewVersion_test.go b/datasetUtils/checkForNewVersion_test.go index 6465dc9..07b9cfe 100644 --- a/datasetUtils/checkForNewVersion_test.go +++ b/datasetUtils/checkForNewVersion_test.go @@ -37,37 +37,6 @@ func TestFetchLatestVersion(t *testing.T) { } } -func TestGenerateDownloadURL(t *testing.T) { - deployLocation := "https://github.com/paulscherrerinstitute/scicat-cli/releases/download" - latestVersion := "0.1.0" - - testCases := []struct { - osName string - expectedURL string - }{ - { - osName: "Linux", - expectedURL: "https://github.com/paulscherrerinstitute/scicat-cli/releases/download/v0.1.0/scicat-cli_v0.1.0_Linux_x86_64.tar.gz", - }, - { - osName: "Windows", - expectedURL: "https://github.com/paulscherrerinstitute/scicat-cli/releases/download/v0.1.0/scicat-cli_v0.1.0_Windows_x86_64.zip", - }, - { - osName: "Darwin", - expectedURL: "https://github.com/paulscherrerinstitute/scicat-cli/releases/download/v0.1.0/scicat-cli_v0.1.0_Darwin_x86_64.tar.gz", - }, - } - - for _, testCase := range testCases { - actualURL := generateDownloadURL(deployLocation, latestVersion, testCase.osName) - - if actualURL != testCase.expectedURL { - t.Errorf("Expected URL to be %s, but got %s", testCase.expectedURL, actualURL) - } - } -} - type MockUserInput struct { Input string } @@ -87,7 +56,7 @@ func TestCheckForNewVersion(t *testing.T) { name: "New version available, non-interactive mode", currentVersion: "0.9.0", mockResponse: `{"tag_name": "v1.0.0"}`, - expectedLog: "You should upgrade to a newer version", + expectedLog: "You can find the download instructions here: https://github.com/paulscherrerinstitute/scicat-cli?tab=readme-ov-file#manual-deployment", }, { name: "No new version available, non-interactive mode",