Skip to content

Commit

Permalink
Add version defaults to install scripts (#324)
Browse files Browse the repository at this point in the history
* added defaults to installers, allow env variable override in win
  • Loading branch information
JakeDawkins authored Mar 5, 2021
1 parent 8a68b84 commit 9f5ca25
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
21 changes: 18 additions & 3 deletions installers/binstall/scripts/nix/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

set -u

BINARY_DOWNLOAD_PREFIX="https://github.com/apollographql/rover/releases/download/$VERSION"
BINARY_DOWNLOAD_PREFIX="https://github.com/apollographql/rover/releases/download"

# Rover version defined in root cargo.toml
PACKAGE_VERSION="v0.0.2"

download_binary_and_run_installer() {
downloader --check
Expand All @@ -26,6 +29,18 @@ download_binary_and_run_installer() {
need_cmd dirname
need_cmd tput

# if $VERSION isn't provided or has 0 length, use version from Rover cargo.toml
# ${VERSION:-} checks if version exists, and if doesn't uses the default
# which is after the :-, which in this case is empty. -z checks for empty str
if [ -z ${VERSION:-} ]; then
# VERSION is either not set or empty
DOWNLOAD_VERSION=$PACKAGE_VERSION
else
# VERSION set and not empty
DOWNLOAD_VERSION=$VERSION
fi


get_architecture || return 1
local _arch="$RETVAL"
assert_nz "$_arch" "arch"
Expand All @@ -37,8 +52,8 @@ download_binary_and_run_installer() {
;;
esac

local _tardir="rover-$VERSION-${_arch}"
local _url="$BINARY_DOWNLOAD_PREFIX/${_tardir}.tar.gz"
local _tardir="rover-$DOWNLOAD_VERSION-${_arch}"
local _url="$BINARY_DOWNLOAD_PREFIX/$DOWNLOAD_VERSION/${_tardir}.tar.gz"
local _dir="$(mktemp -d 2>/dev/null || ensure mktemp -d -t rover)"
local _file="$_dir/input.tar.gz"
local _rover="$_dir/rover$_ext"
Expand Down
17 changes: 13 additions & 4 deletions installers/binstall/scripts/windows/install.ps1
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# version found in Rover's Cargo.toml
$package_version = 'v0.0.2'

function Install-Binary() {
$old_erroractionpreference = $ErrorActionPreference
$ErrorActionPreference = 'stop'

$version = "0.0.2"

Initialize-Environment

$exe = Download($version)
# If the VERSION env var is set, we use it instead
# of the version defined in Rover's cargo.toml
$download_version = if (Test-Path env:VERSION) {
$Env:VERSION
} else {
$package_version
}

$exe = Download($download_version)

Invoke-Installer($exe)

$ErrorActionPreference = $old_erroractionpreference
}

function Download($version) {
$url = "https://github.com/apollographql/rover/releases/download/v$version/rover-v$version-x86_64-pc-windows-msvc.tar.gz"
$url = "https://github.com/apollographql/rover/releases/download/$version/rover-$version-x86_64-pc-windows-msvc.tar.gz"
"Downloading Rover from $url" | Out-Host
$tmp = New-Temp-Dir
$dir_path = "$tmp\rover.tar.gz"
Expand Down

0 comments on commit 9f5ca25

Please sign in to comment.