Skip to content

Commit

Permalink
refactor: adjust installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
aweris committed Aug 7, 2023
1 parent 3520db5 commit 600e5c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ You can download the latest release of `gale` from the [releases page](https://g
or you can install `gale` using:

```bash!
curl https://raw.githubusercontent.com/aweris/gale/main/hack/install_gale.sh | sh
curl -sfLo install.sh https://raw.githubusercontent.com/aweris/gale/main/hack/install.sh; sh ./install.sh
```

The following command will install latest version of `gale` to your current directory. You can also specify following environment variables,

- `VERSION` to specify the version of `gale` to install, e.g. `VERSION=v0.0.1` default is `latest`
- `INSTALL_DIR` to specify the directory to install `gale` to, e.g. `INSTALL_DIR=/usr/local/bin` default is current directory
- `GALE_VERSION` to specify the version of `gale` to install, e.g. `GALE_VERSION=v0.0.1` default is `latest`
- `BIN_DIR` to specify the directory to install `gale` to, e.g. `BIN_DIR=/usr/local/bin` default is current directory

```bash!
curl https://raw.githubusercontent.com/aweris/gale/main/hack/install_gale.sh | sudo VERSION=v0.0.1 INSTALL_DIR=/usr/local/bin sh
Expand Down
14 changes: 7 additions & 7 deletions hack/install_gale.sh → hack/install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash

RELEASE=$(curl -s "https://api.github.com/repos/aweris/gale/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
VERSION="${VERSION:-${RELEASE}}"
INSTALL_DIR="${INSTALL_DIR:-.}"
GALE_VERSION="${GALE_VERSION:-${RELEASE}}"
BIN_DIR="${BIN_DIR:-.}"

function install_gale() {
local version=$1
Expand All @@ -13,11 +13,11 @@ function install_gale() {

echo "Downloading ${download_url}"

curl -sL "${download_url}" | tar xz -C "${INSTALL_DIR}"
curl -sL "${download_url}" | tar xz -C "${BIN_DIR}"

echo "Installed gale ${version} to ${INSTALL_DIR}"
echo "Installed gale ${version} to ${BIN_DIR}"

"${INSTALL_DIR}/gale" version
"${BIN_DIR}/gale" version

echo "Done."
}
Expand All @@ -29,12 +29,12 @@ function main() {
local arch
arch=$(uname -m | tr '[:upper:]' '[:lower:]')

if [[ -z "${VERSION}" ]]; then
if [[ -z "${GALE_VERSION}" ]]; then
echo "failed to get latest version from GitHub API"
exit 1
fi

install_gale "${VERSION}" "${os}" "${arch}"
install_gale "${GALE_VERSION}" "${os}" "${arch}"
}

main "$@"

0 comments on commit 600e5c3

Please sign in to comment.