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

feat: support install.sh script #155

Merged
merged 3 commits into from
Jan 28, 2025
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
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,15 @@ jobs:

- name: Test
run: uv run poe test

test-install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: run install.sh
run: ./install.sh

- name: run terranova
run: |-
terranova --version
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ brew tap elastic/terranova
brew install terranova
```

### Single-line installation

```shell
curl -sSL https://raw.githubusercontent.com/elastic/terranova/0.6.5/install.sh | sh -s
```

If you use `wget` instead:

```shell
wget -qO- https://raw.githubusercontent.com/elastic/terranova/0.6.5/install.sh | sh -s
```

That will download `terranova`, put it inside `/usr/local/bin/` and give it execution rights with `chmod`.

### How to install as Standalone

```bash
Expand Down
25 changes: 25 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env sh

set -o errexit
set -o nounset

## NOTE: Bump this version when a new release.
VERSION="0.6.4"
OS=$(uname -s| tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m| tr '[:upper:]' '[:lower:]')
if [ "${ARCH}" = "aarch64" ] ; then
ARCH_SUFFIX=arm64
elif [ "${ARCH}" = "x86_64" ] ; then
ARCH_SUFFIX=amd64
elif [ "${ARCH}" = "arm64" ] ; then
ARCH_SUFFIX=arm64
else
echo "Unsupported architecture: ${ARCH}"
exit 1
fi

URL="https://github.com/elastic/terranova/releases/download/${VERSION}/terranova-${VERSION}-${OS}-${ARCH_SUFFIX}"

LOCATION="/usr/local/bin"
curl -sSLo "$LOCATION/terranova" "$URL"
chmod +x "$LOCATION/terranova"
27 changes: 27 additions & 0 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ def __set_version(version: str) -> None:
raise err


def __set_version_install_file(version: str) -> None:
# Update install file version version
try:
data = Constants.INSTALL_PATH.read_text()
except Exception as err:
print(
f"The `{Constants.INSTALL_PATH.as_posix()}` can't be read",
file=sys.stderr,
)
raise err

data = re.sub(
r"VERSION=\"(.*)\"", f'VERSION="{version}"', data, count=1
)
try:
Constants.INSTALL_PATH.write_text(data)
except Exception as err:
print(
f"The `{Constants.INSTALL_PATH.as_posix()}` file can't be written",
file=sys.stderr,
)
raise err


def pre() -> None:
# Ensure we have inputs
release_version = os.getenv("RELEASE_VERSION")
Expand All @@ -90,6 +114,9 @@ def pre() -> None:
# Update all files
__set_version(release_version)

# Update install file
__set_version_install_file(release_version)

# Push release branch
git("add", "--all", _out=sys.stdout, _err=sys.stderr)
git(
Expand Down
1 change: 1 addition & 0 deletions scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Constants:
PYRIGHTCONFIG_PATH: Final[Path] = Path("pyrightconfig.json")
REGISTRY_URL: str = os.getenv("REGISTRY_URL", "local.dev")
TERRANOVA_INIT_PATH: Final[Path] = Path("./terranova/__init__.py")
INSTALL_PATH: Final[Path] = Path("install.sh")


def fatal(msg: str, err: Exception | None = None) -> NoReturn:
Expand Down
Loading