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 support for installing nightlies #7

Merged
merged 2 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
28 changes: 26 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,33 @@ jobs:
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: asdf-vm/actions/plugin-test@v2
- name: "Fetch latest Scarb version from GitHub releases"
id: version
shell: pwsh
run: |
$location = (Invoke-WebRequest -Uri "https://github.com/software-mansion/scarb/releases/latest" -Method Head -MaximumRedirection 0 -SkipHttpErrorCheck -ErrorAction Ignore).Headers.Location
$latest_version = ($location -replace '^.*/v','')
echo "Latest Scarb version found is $latest_version"
echo "LATEST_VERSION=$latest_version" >> $env:GITHUB_OUTPUT

- name: "Check Scarb latest"
uses: asdf-vm/actions/plugin-test@v2
with:
command: scarb --version | grep "scarb ${{ steps.version.outputs.LATEST_VERSION }}"

- name: "Check Scarb v0.5.2"
uses: asdf-vm/actions/plugin-test@v2
with:
skip_install: true
version: 0.5.2
command: scarb --version | grep "scarb 0.5.2"

- name: "Check Scarb nightly-2023-08-10"
uses: asdf-vm/actions/plugin-test@v2
with:
command: scarb --version
skip_install: true
version: nightly-2023-08-10
command: scarb --version | grep "scarb 0.6.0+nightly-2023-08-10"

shellcheck:
runs-on: ubuntu-latest
Expand Down
15 changes: 13 additions & 2 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -euo pipefail

GH_REPO="https://github.com/software-mansion/scarb"
GH_NIGHTLIES_REPO="https://github.com/software-mansion/scarb-nightlies"
TOOL_NAME="scarb"
TOOL_TEST="scarb --version"

Expand Down Expand Up @@ -42,8 +43,18 @@ download_release() {
get_architecture || fail "Could not determine system architecture."
local _arch="$RETVAL"

local _tarball="scarb-v${version}-${_arch}.tar.gz"
url="$GH_REPO/releases/download/v${version}/${_tarball}"
local repository tag

if grep -q "nightly" <<<"$version"; then
szymmis marked this conversation as resolved.
Show resolved Hide resolved
repository=$GH_NIGHTLIES_REPO
tag=$version
else
repository=$GH_REPO
tag="v$version"
fi

local _tarball="scarb-${tag}-${_arch}.tar.gz"
url="${repository}/releases/download/${tag}/${_tarball}"

echo "* Downloading $TOOL_NAME release $version..."
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
Expand Down