From 9e422df2c82041d1c5d14ac9a0ca8069b61eab2d Mon Sep 17 00:00:00 2001 From: Michael Sverdlov Date: Sun, 21 Jan 2024 17:26:50 +0200 Subject: [PATCH] Improve JFrog CLI install/get bash scripts (#2227) --- .github/workflows/scriptTests.yml | 21 ++++++++++++++------- build/getcli/jf.sh | 30 ++++++++++++++++-------------- build/getcli/jfrog.sh | 30 ++++++++++++++++-------------- build/installcli/jf.sh | 30 ++++++++++++++++-------------- build/installcli/jfrog.sh | 30 ++++++++++++++++-------------- build/setupcli/jf.sh | 30 ++++++++++++++++-------------- 6 files changed, 94 insertions(+), 77 deletions(-) diff --git a/.github/workflows/scriptTests.yml b/.github/workflows/scriptTests.yml index 11e8b6f47..82b1c9a10 100644 --- a/.github/workflows/scriptTests.yml +++ b/.github/workflows/scriptTests.yml @@ -15,18 +15,25 @@ jobs: name: Script tests (${{ matrix.suite.os }}) defaults: run: - shell: bash + shell: sh strategy: fail-fast: false matrix: suite: - - os: "ubuntu" + - os: "ubuntu-latest" + + - os: "ubuntu-20.04" + + - os: "macos-latest" - - os: "macos" + - os: "macos-11" + + - os: "windows-latest" + osSuffix: ".exe" - - os: "windows" + - os: "windows-2019" osSuffix: ".exe" - runs-on: ${{ matrix.suite.os }}-latest + runs-on: ${{ matrix.suite.os }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -64,13 +71,13 @@ jobs: run: | sh build/build.sh ./jf${{ matrix.suite.osSuffix }} --version - if: ${{ matrix.suite.os != 'windows' }} + if: contains( matrix.suite.os, 'windows') - name: Test Build CLI - bat run: | build/build.bat ./jf${{ matrix.suite.osSuffix }} --version - if: ${{ matrix.suite.os == 'windows' }} + if: contains( matrix.suite.os, 'windows') # Prior to the release, we set the new version in the package.json files, introducing the prereleased version. # This adjustment may result in an attempt to download a version that hasn't been published to releases.jfrog.io yet. diff --git a/build/getcli/jf.sh b/build/getcli/jf.sh index 7b1f5eeff..752b82191 100644 --- a/build/getcli/jf.sh +++ b/build/getcli/jf.sh @@ -1,29 +1,31 @@ -#!/bin/bash +#!/bin/sh +set -u + +# This script is downloading the OS-specific JFrog CLI binary with the name - 'jf' CLI_OS="na" CLI_MAJOR_VER="v2-jf" VERSION="[RELEASE]" +FILE_NAME="jf" -if [ $# -eq 1 ] -then +if [ $# -eq 1 ]; then VERSION=$1 echo "Downloading version $VERSION of JFrog CLI..." else echo "Downloading the latest version of JFrog CLI..." fi -if echo "${OSTYPE}" | grep -q msys; then +if uname -s | grep -q -E -i "(cygwin|mingw|msys|windows)"; then CLI_OS="windows" - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-windows-amd64/jf.exe" - FILE_NAME="jf.exe" -elif echo "${OSTYPE}" | grep -q darwin; then + ARCH="amd64" + FILE_NAME="${FILE_NAME}.exe" +elif uname -s | grep -q -i "darwin"; then CLI_OS="mac" - if [[ $(uname -m) == 'arm64' ]]; then - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-arm64/jf" + if [ "$(uname -m)" = "arm64" ]; then + ARCH="arm64" else - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-386/jf" + ARCH="386" fi - FILE_NAME="jf" else CLI_OS="linux" MACHINE_TYPE="$(uname -m)" @@ -54,9 +56,9 @@ else exit 1 ;; esac - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/jf" - FILE_NAME="jf" fi +URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/${FILE_NAME}" +echo "Downloading from: $URL" curl -XGET "$URL" -L -k -g > $FILE_NAME -chmod u+x $FILE_NAME +chmod +x $FILE_NAME diff --git a/build/getcli/jfrog.sh b/build/getcli/jfrog.sh index 1debb922e..8cef09787 100644 --- a/build/getcli/jfrog.sh +++ b/build/getcli/jfrog.sh @@ -1,29 +1,31 @@ -#!/bin/bash +#!/bin/sh +set -u + +# This script is downloading the OS-specific JFrog CLI binary with the name - 'jfrog' CLI_OS="na" CLI_MAJOR_VER="v2" VERSION="[RELEASE]" +FILE_NAME="jfrog" -if [ $# -eq 1 ] -then +if [ $# -eq 1 ]; then VERSION=$1 echo "Downloading version $VERSION of JFrog CLI..." else echo "Downloading the latest version of JFrog CLI..." fi -if echo "${OSTYPE}" | grep -q msys; then +if uname -s | grep -q -E -i "(cygwin|mingw|msys|windows)"; then CLI_OS="windows" - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-windows-amd64/jfrog.exe" - FILE_NAME="jfrog.exe" -elif echo "${OSTYPE}" | grep -q darwin; then + ARCH="amd64" + FILE_NAME="${FILE_NAME}.exe" +elif uname -s | grep -q -i "darwin"; then CLI_OS="mac" - if [[ $(uname -m) == 'arm64' ]]; then - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-arm64/jfrog" + if [ "$(uname -m)" = "arm64" ]; then + ARCH="arm64" else - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-386/jfrog" + ARCH="386" fi - FILE_NAME="jfrog" else CLI_OS="linux" MACHINE_TYPE="$(uname -m)" @@ -54,9 +56,9 @@ else exit 1 ;; esac - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/jfrog" - FILE_NAME="jfrog" fi +URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/${FILE_NAME}" +echo "Downloading from: $URL" curl -XGET "$URL" -L -k -g > $FILE_NAME -chmod u+x $FILE_NAME \ No newline at end of file +chmod +x $FILE_NAME \ No newline at end of file diff --git a/build/installcli/jf.sh b/build/installcli/jf.sh index 4619708d4..c8c15a13b 100755 --- a/build/installcli/jf.sh +++ b/build/installcli/jf.sh @@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh +set -u + +# This script is downloading the OS-specific JFrog CLI binary with the name - 'jf', and adds it to PATH CLI_OS="na" CLI_MAJOR_VER="v2-jf" VERSION="[RELEASE]" +FILE_NAME="jf" -if [ $# -eq 1 ] -then +if [ $# -eq 1 ]; then VERSION=$1 echo "Downloading version $VERSION of JFrog CLI..." else @@ -13,18 +16,17 @@ else fi echo "" -if echo "${OSTYPE}" | grep -q msys; then +if uname -s | grep -q -E -i "(cygwin|mingw|msys|windows)"; then CLI_OS="windows" - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-windows-amd64/jf.exe" - FILE_NAME="jf.exe" -elif echo "${OSTYPE}" | grep -q darwin; then + ARCH="amd64" + FILE_NAME="${FILE_NAME}.exe" +elif uname -s | grep -q -i "darwin"; then CLI_OS="mac" - if [[ $(uname -m) == 'arm64' ]]; then - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-arm64/jf" + if [ "$(uname -m)" = "arm64" ]; then + ARCH="arm64" else - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-386/jf" + ARCH="386" fi - FILE_NAME="jf" else CLI_OS="linux" MACHINE_TYPE="$(uname -m)" @@ -55,12 +57,12 @@ else exit 1 ;; esac - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/jf" - FILE_NAME="jf" fi +URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/${FILE_NAME}" +echo "Downloading from: $URL" curl -XGET "$URL" -L -k -g > $FILE_NAME -chmod u+x $FILE_NAME +chmod +x $FILE_NAME # Move executable to a destination in path. # Order is by destination priority. diff --git a/build/installcli/jfrog.sh b/build/installcli/jfrog.sh index 80ec7c3f3..bda6b22eb 100755 --- a/build/installcli/jfrog.sh +++ b/build/installcli/jfrog.sh @@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh +set -u + +# This script is downloading the OS-specific JFrog CLI binary with the name - 'jfrog', and adds it to PATH CLI_OS="na" CLI_MAJOR_VER="v2" VERSION="[RELEASE]" +FILE_NAME="jfrog" -if [ $# -eq 1 ] -then +if [ $# -eq 1 ]; then VERSION=$1 echo "Downloading version $VERSION of JFrog CLI..." else @@ -13,18 +16,17 @@ else fi echo "" -if echo "${OSTYPE}" | grep -q msys; then +if uname -s | grep -q -E -i "(cygwin|mingw|msys|windows)"; then CLI_OS="windows" - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-windows-amd64/jfrog.exe" - FILE_NAME="jfrog.exe" -elif echo "${OSTYPE}" | grep -q darwin; then + ARCH="amd64" + FILE_NAME="${FILE_NAME}.exe" +elif uname -s | grep -q -i "darwin"; then CLI_OS="mac" - if [[ $(uname -m) == 'arm64' ]]; then - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-arm64/jfrog" + if [ "$(uname -m)" = "arm64" ]; then + ARCH="arm64" else - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-386/jfrog" + ARCH="386" fi - FILE_NAME="jfrog" else CLI_OS="linux" MACHINE_TYPE="$(uname -m)" @@ -55,12 +57,12 @@ else exit 1 ;; esac - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/jfrog" - FILE_NAME="jfrog" fi +URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/${FILE_NAME}" +echo "Downloading from: $URL" curl -XGET "$URL" -L -k -g > $FILE_NAME -chmod u+x $FILE_NAME +chmod +x $FILE_NAME # Move executable to a destination in path. # Order is by destination priority. diff --git a/build/setupcli/jf.sh b/build/setupcli/jf.sh index ecf68f0cc..6adcd7af3 100755 --- a/build/setupcli/jf.sh +++ b/build/setupcli/jf.sh @@ -1,8 +1,12 @@ -#!/bin/bash +#!/bin/sh +set -u + +# This script is downloading the OS-specific JFrog CLI binary with the name - 'jf', adds it to PATH and prints greeting message CLI_OS="na" CLI_MAJOR_VER="v2-jf" VERSION="[RELEASE]" +FILE_NAME="jf" SETUP_COMMAND="jf setup" GREEN_COLOR='\033[0;32m' REMOVE_COLOR='\033[0m' @@ -11,24 +15,22 @@ print_installation_greeting () { echo "${GREEN_COLOR}Thank you for installing JFrog CLI! 🐸 ${REMOVE_COLOR}" } -if [ $# -eq 1 ] -then +if [ $# -eq 1 ]; then SETUP_COMMAND="$SETUP_COMMAND $1" fi echo "Downloading the latest version of JFrog CLI..." -if echo "${OSTYPE}" | grep -q msys; then +if uname -s | grep -q -E -i "(cygwin|mingw|msys|windows)"; then CLI_OS="windows" - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-windows-amd64/jf.exe" - FILE_NAME="jf.exe" -elif echo "${OSTYPE}" | grep -q darwin; then + ARCH="amd64" + FILE_NAME="${FILE_NAME}.exe" +elif uname -s | grep -q -i "darwin"; then CLI_OS="mac" - if [[ $(uname -m) == 'arm64' ]]; then - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-arm64/jf" + if [ "$(uname -m)" = "arm64" ]; then + ARCH="arm64" else - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-mac-386/jf" + ARCH="386" fi - FILE_NAME="jf" else CLI_OS="linux" MACHINE_TYPE="$(uname -m)" @@ -59,12 +61,12 @@ else exit 1 ;; esac - URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/jf" - FILE_NAME="jf" fi +URL="https://releases.jfrog.io/artifactory/jfrog-cli/${CLI_MAJOR_VER}/${VERSION}/jfrog-cli-${CLI_OS}-${ARCH}/${FILE_NAME}" +echo "Downloading from: $URL" curl -XGET "$URL" -L -k -g > $FILE_NAME -chmod u+x $FILE_NAME +chmod +x $FILE_NAME # Move executable to a destination in path. # Order is by destination priority.