Skip to content

Commit

Permalink
feat: Allow to download nightly binaries using `asdf install odo ref:…
Browse files Browse the repository at this point in the history
…nightly` (#73)

This merges pull request #73 from asdf-community/64-feat-download-nightly-binaries-of-odo
  • Loading branch information
rm3l authored Apr 29, 2024
2 parents c8c792c + 98d35bf commit dd9d1f0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 6 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
version: ["2.5.1", "3.0.0-rc2", "3.15.0"]
version: ["2.5.1", "3.0.0-rc2", "3.15.0", "ref:nightly"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand Down Expand Up @@ -181,10 +181,14 @@ jobs:
- name: Test odo v${{ matrix.version }}
run: |
res=$(odo version | grep -F "v${{ matrix.version }}" || echo false)
grepWord="v${{ matrix.version }}"
if [[ "${{ matrix.version }}" == "ref:nightly" ]]; then
grepWord="nightly"
fi
res=$(odo version | grep -F "${grepWord}" || echo false)
if [[ "$res" == "false" ]]; then
version_output=$(odo version 2>&1 || true)
echo "Expected 'odo version' to contain \"v${{ matrix.version }}\", but got $version_output"
echo "Expected 'odo version' to contain \"${grepWord}\", but got $version_output"
exit 1
fi
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ Now you can pick and install any version from the list above:
asdf install odo <version>
```

## How do I install nightly releases of odo?

Run the command below:
```shell
asdf install odo ref:nightly
```

## How do I install odo from specific (unreleased) Git commits or branches?

NOTE: This will download and build `odo` on your machine. Make sure you installed these optional [dependencies](README.md#dependencies), besides the mandatory ones: `unzip`, `git`, [Golang](https://go.dev/doc/install) and `make`.
Expand Down Expand Up @@ -171,7 +178,7 @@ asdf uninstall odo <version>
```

## How do I reinstall an already installed version of odo?
Because of the way `asdf` works (by enforcing exact versions), if you installed odo from a development branch and wish to update it, you need to reinstall that specific version.
Because of the way `asdf` works (by enforcing exact versions), if you installed odo from a development branch (or a nightly release) and wish to update it, you need to reinstall that specific version.
To reinstall an already installed version of odo, first [uninstall it](README.md#how-do-i-uninstall-a-given-version-of-odo), and then [install it](README.md#install) again.

`latest` is a special version number that `asdf` dynamically resolves to the latest known version at the time of execution. So running `asdf install odo latest` might install a newer version of `odo`, if a newer version is available at the time the command is executed.
Expand Down
7 changes: 6 additions & 1 deletion bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ if [[ "$ASDF_INSTALL_TYPE" == "ref" ]]; then
dl_dir="$ASDF_DOWNLOAD_PATH"
gh_repo="${ASDF_GITHUB_REPO_FOR_ODO:-$GH_REPO}"
gh_ref="${ASDF_INSTALL_VERSION}"
download_ref "$dl_dir" "$gh_repo" "$gh_ref"
if [[ "$gh_ref" == "nightly" ]]; then
release_file="$ASDF_DOWNLOAD_PATH/bin/$TOOL_NAME"
download_nightly "$release_file"
else
download_ref "$dl_dir" "$gh_repo" "$gh_ref"
fi
else
release_file="$ASDF_DOWNLOAD_PATH/bin/$TOOL_NAME"
download_release "$ASDF_INSTALL_VERSION" "$release_file"
Expand Down
46 changes: 45 additions & 1 deletion lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GH_REPO="https://github.com/redhat-developer/odo"
TOOL_NAME="odo"
TOOL_TEST="odo version"
BASE_DL_URL="https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/$TOOL_NAME"
NIGHTLY_BASE_DL_URL="https://s3.eu-de.cloud-object-storage.appdomain.cloud/$TOOL_NAME-nightly-builds"

ansi() {
if [ -n "$TERM" ]; then
Expand Down Expand Up @@ -153,6 +154,49 @@ download_ref() {
rm -rf "${extraction_tmp_dir}" "$filename"
}

download_nightly() {
local os_arch os arch version filename url

if [ -n "${ASDF_ODO_BINARY_OS_ARCH:-}" ]; then
os_arch="$ASDF_ODO_BINARY_OS_ARCH"
log_verbose "Using pre-defined ASDF_ODO_BINARY_OS_ARCH environment variable: $ASDF_ODO_BINARY_OS_ARCH"
else
os=${ASDF_ODO_BINARY_OS:-"$(uname_os)"}
log_verbose "Using Operating System: $os"
arch=${ASDF_ODO_BINARY_ARCH:-"$(uname_arch)"}
log_verbose "Using Processor Architecture: $arch"
os_arch="${os}-${arch}"
fi

filename="$1"

local binaryExtension
if [[ "$os_arch" == "windows-"* ]]; then
binaryExtension=".exe"
else
binaryExtension=""
fi

local toolBinaryNameWithExtension="$TOOL_NAME-${os_arch}${binaryExtension}"
url="${NIGHTLY_BASE_DL_URL}/${toolBinaryNameWithExtension}"

echo "* Downloading $TOOL_NAME nightly release, for $os_arch..."
log_verbose "Download URL: $url, using curl options: '${curl_opts[@]}'"
curl "${curl_opts[@]}" -o "$filename" -C - "$url" || fail "Could not download $url"
log_verbose "Downloaded file and saved it to $filename"

if [[ "${ASDF_ODO_CHECKS_SKIP_FILE_CHECKSUM:-false}" != "true" ]]; then
echo "* Verifying filename integrity..."
shaurl="${url}.sha256"
log_verbose "Download URL: $shaurl, using curl options: '${curl_opts[@]}'"
shafilename="$filename.sha256"
curl "${curl_opts[@]}" -o "$shafilename" -C - "$shaurl" || fail "Could not download $shaurl"
(echo "$(<$shafilename) $filename" | shasum -a 256 --check) || fail "Could not check integrity of downloaded file"
fi

chmod a+x "$filename"
}

download_release() {
local os_arch os arch version filename url

Expand Down Expand Up @@ -219,7 +263,7 @@ install_version() {

(
mkdir -p "$install_path"/bin
if [[ "$install_type" == "ref" ]]; then
if [[ "$install_type" == "ref" && "$version" != "nightly" ]]; then
cd "$ASDF_DOWNLOAD_PATH/src"
local git_commit_for_version
if [[ "${ASDF_GITHUB_REPO_FOR_ODO:-}" == "" ]]; then
Expand Down

0 comments on commit dd9d1f0

Please sign in to comment.