Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version defaults to install scripts #324

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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