|
| 1 | +# Spec: installer |
| 2 | + |
| 3 | +A one-liner shell script that downloads and installs the correct pre-built `exasol-saas` binary for the current platform directly from the latest GitHub release. |
| 4 | + |
| 5 | +## Output file |
| 6 | + |
| 7 | +`install.sh` (repo root) |
| 8 | + |
| 9 | +## Purpose |
| 10 | + |
| 11 | +Allow users to install the CLI without cloning the repo, building from source, or manually selecting the right binary. A single `curl | sh` command handles everything. |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +```bash |
| 16 | +curl -fsSL https://raw.githubusercontent.com/exasol-labs/saas-cli/main/install.sh | sh |
| 17 | +``` |
| 18 | + |
| 19 | +Users may also override the install directory: |
| 20 | + |
| 21 | +```bash |
| 22 | +curl -fsSL .../install.sh | INSTALL_DIR=/usr/local/bin sh |
| 23 | +``` |
| 24 | + |
| 25 | +## Platform detection |
| 26 | + |
| 27 | +Detect OS and architecture at runtime using `uname`. |
| 28 | + |
| 29 | +### Supported platforms |
| 30 | + |
| 31 | +| OS | Arch | Binary name | |
| 32 | +|---|---|---| |
| 33 | +| macOS | x86_64 / amd64 | `exasol-saas-darwin-amd64` | |
| 34 | +| macOS | arm64 (Apple Silicon) | `exasol-saas-darwin-arm64` | |
| 35 | +| Linux | x86_64 / amd64 | `exasol-saas-linux-amd64` | |
| 36 | +| Linux | aarch64 / arm64 | `exasol-saas-linux-arm64` | |
| 37 | + |
| 38 | +Windows is not supported by this script (Windows users should download manually from the releases page). |
| 39 | + |
| 40 | +If the detected OS/arch combination is unsupported, print a clear error with a link to the releases page and exit non-zero: |
| 41 | +``` |
| 42 | +Error: unsupported platform: <OS>/<arch> |
| 43 | +Download manually from: https://github.com/exasol-labs/saas-cli/releases |
| 44 | +``` |
| 45 | + |
| 46 | +## Version resolution |
| 47 | + |
| 48 | +By default, resolve the latest release version from the GitHub API: |
| 49 | + |
| 50 | +```bash |
| 51 | +VERSION=$(curl -fsSL https://api.github.com/repos/exasol-labs/saas-cli/releases/latest \ |
| 52 | + | grep '"tag_name"' | sed 's/.*"tag_name": *"\(.*\)".*/\1/') |
| 53 | +``` |
| 54 | + |
| 55 | +Users may pin a specific version via the `VERSION` environment variable: |
| 56 | + |
| 57 | +```bash |
| 58 | +curl -fsSL .../install.sh | VERSION=v0.1.0 sh |
| 59 | +``` |
| 60 | + |
| 61 | +If version resolution fails (e.g. no network access to GitHub API, no releases published yet), print a clear error and exit non-zero. |
| 62 | + |
| 63 | +## Download |
| 64 | + |
| 65 | +Construct the download URL from the resolved version and binary name: |
| 66 | + |
| 67 | +``` |
| 68 | +https://github.com/exasol-labs/saas-cli/releases/download/<VERSION>/<BINARY> |
| 69 | +``` |
| 70 | + |
| 71 | +Download to a temporary file using `curl -fsSL`. On failure, print a clear error and exit non-zero. |
| 72 | + |
| 73 | +## Install directory |
| 74 | + |
| 75 | +Default install directory: `/usr/local/bin`. |
| 76 | + |
| 77 | +Override via the `INSTALL_DIR` environment variable. |
| 78 | + |
| 79 | +After downloading, move the binary to `$INSTALL_DIR/exasol-saas` and make it executable (`chmod +x`). |
| 80 | + |
| 81 | +If the install directory is not writable, the `mv` will fail and bash's `-e` flag exits with a clear OS error. Do not attempt to use `sudo` automatically — the user should either run with appropriate permissions or override `INSTALL_DIR` to a writable path. |
| 82 | + |
| 83 | +## Verification |
| 84 | + |
| 85 | +After installing, run `exasol-saas --version` to confirm the binary works. Print the output. |
| 86 | + |
| 87 | +On success, print: |
| 88 | +``` |
| 89 | +exasol-saas <version> installed to <install-dir>/exasol-saas |
| 90 | +``` |
| 91 | + |
| 92 | +## Error handling |
| 93 | + |
| 94 | +- Use `set -euo pipefail`. |
| 95 | +- Use `curl -fsSL` for all downloads so HTTP errors cause immediate failure. |
| 96 | +- Clean up the temporary file on exit (success or failure) using a `trap`. |
| 97 | + |
| 98 | +## Prerequisites |
| 99 | + |
| 100 | +The script requires only `curl` and basic POSIX tools (`uname`, `mv`, `chmod`). Both are available by default on macOS and all major Linux distributions. No additional dependencies. |
| 101 | + |
| 102 | +## Example output |
| 103 | + |
| 104 | +``` |
| 105 | +Detecting platform... darwin/arm64 |
| 106 | +Resolving latest version... v0.1.0 |
| 107 | +Downloading exasol-saas-darwin-arm64... |
| 108 | +Installing to /usr/local/bin/exasol-saas... |
| 109 | +exasol-saas v0.1.0 installed to /usr/local/bin/exasol-saas |
| 110 | +``` |
0 commit comments