From 5bd42e12350382298bb4b015c7eeaefe5a7ff659 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 23 Jan 2025 21:30:04 +0100 Subject: [PATCH 1/3] feat: support install.sh script --- README.md | 14 ++++++++++++++ install.sh | 25 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 install.sh diff --git a/README.md b/README.md index c3d6470..a4aa8b0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..2e7d234 --- /dev/null +++ b/install.sh @@ -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 + GVM_ARCH_SUFFIX=arm64 +elif [ "${ARCH}" = "x86_64" ] ; then + GVM_ARCH_SUFFIX=amd64 +elif [ "${ARCH}" = "arm64" ] ; then + GVM_ARCH_SUFFIX=arm64 +else + echo "Unsupported architecture: ${ARCH}" + exit 1 +fi + +URL="https://github.com/elastic/terranova/releases/download/${VERSION}/terranova-${VERSION}-${OS}-${GVM_ARCH_SUFFIX}" + +LOCATION="/usr/local/bin" +curl -sSLo "$LOCATION/terranova" "$URL" +chmod +x "$LOCATION/terranova" From 572b48761397c43406b330cbe58a8467e31658c0 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 23 Jan 2025 21:37:05 +0100 Subject: [PATCH 2/3] automate bump pre-release --- .github/workflows/ci.yml | 12 ++++++++++++ install.sh | 2 +- scripts/release.py | 27 +++++++++++++++++++++++++++ scripts/utils.py | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c434867..ab55f5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/install.sh b/install.sh index 2e7d234..185bcce 100755 --- a/install.sh +++ b/install.sh @@ -4,7 +4,7 @@ set -o errexit set -o nounset ## NOTE: Bump this version when a new release. -VERSION=0.6.4 +VERSION="0.6.4" OS=$(uname -s| tr '[:upper:]' '[:lower:]') ARCH=$(uname -m| tr '[:upper:]' '[:lower:]') if [ "${ARCH}" = "aarch64" ] ; then diff --git a/scripts/release.py b/scripts/release.py index bf9b9cb..7c02257 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -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") @@ -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( diff --git a/scripts/utils.py b/scripts/utils.py index cfbc4a2..05ea547 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -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: From bd44f6be5440d4e60e18c7f9b10ce95b8b4ff53b Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 23 Jan 2025 21:39:08 +0100 Subject: [PATCH 3/3] rename --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 185bcce..3c521ac 100755 --- a/install.sh +++ b/install.sh @@ -8,17 +8,17 @@ VERSION="0.6.4" OS=$(uname -s| tr '[:upper:]' '[:lower:]') ARCH=$(uname -m| tr '[:upper:]' '[:lower:]') if [ "${ARCH}" = "aarch64" ] ; then - GVM_ARCH_SUFFIX=arm64 + ARCH_SUFFIX=arm64 elif [ "${ARCH}" = "x86_64" ] ; then - GVM_ARCH_SUFFIX=amd64 + ARCH_SUFFIX=amd64 elif [ "${ARCH}" = "arm64" ] ; then - GVM_ARCH_SUFFIX=arm64 + ARCH_SUFFIX=arm64 else echo "Unsupported architecture: ${ARCH}" exit 1 fi -URL="https://github.com/elastic/terranova/releases/download/${VERSION}/terranova-${VERSION}-${OS}-${GVM_ARCH_SUFFIX}" +URL="https://github.com/elastic/terranova/releases/download/${VERSION}/terranova-${VERSION}-${OS}-${ARCH_SUFFIX}" LOCATION="/usr/local/bin" curl -sSLo "$LOCATION/terranova" "$URL"