From c5b5d9d736581c85218da3581c02b7c0c450e388 Mon Sep 17 00:00:00 2001 From: ascandone Date: Thu, 10 Jul 2025 20:16:03 +0200 Subject: [PATCH 1/6] create install script --- install.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 00000000..ff418ec6 --- /dev/null +++ b/install.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +set -e + +echo "👉 Detecting platform..." + +# Detect OS +OS="$(uname -s)" +case "$OS" in + Linux*) PLATFORM="Linux";; + Darwin*) PLATFORM="Darwin";; + MINGW*|MSYS*|CYGWIN*|Windows_NT) PLATFORM="Windows";; + *) echo "❌ Unsupported OS: $OS"; exit 1;; +esac + +# Detect architecture +ARCH="$(uname -m)" +case "$ARCH" in + x86_64) ARCH="x86_64";; + amd64) ARCH="x86_64";; # Just in case + arm64|aarch64) ARCH="arm64";; + *) echo "❌ Unsupported architecture: $ARCH"; exit 1;; +esac + +echo "✅ Platform: $PLATFORM" +echo "✅ Architecture: $ARCH" + + +# https://github.com/formancehq/numscript/releases/download/v0.0.18/numscript_.0.0.18_Darwin_arm64.tar.gz +# Get latest release tag +LATEST_TAG=$(curl -sI https://github.com/formancehq/numscript/releases/latest | grep -i location | awk -F '/' '{print $NF}' | tr -d '\r') + +echo "📦 Latest tag: $LATEST_TAG" + +# Determine file extension +if [ "$PLATFORM" = "Windows" ]; then + EXT="zip" +else + EXT="tar.gz" +fi + +# Build file name and URL +FILENAME="numscript_.${LATEST_TAG#v}_${PLATFORM}_${ARCH}.${EXT}" +URL="https://github.com/formancehq/numscript/releases/download/$LATEST_TAG/$FILENAME" + +echo "⬇️ Downloading: $URL" +curl -L -o "$FILENAME" "$URL" + +# Extract and install +if [ "$PLATFORM" = "Windows" ]; then + unzip "$FILENAME" + BIN="numscript.exe" +else + tar -xvf "$FILENAME" + BIN="numscript" +fi + +sudo mv "$BIN" /usr/local/bin/ +chmod +x /usr/local/bin/"$BIN" + +rm "$FILENAME" + +echo "✅ Installed $BIN to /usr/local/bin" +echo "🎉 Done!" From f70eb619e84c8ca08ba204c9b4c66f937490cc1f Mon Sep 17 00:00:00 2001 From: ascandone Date: Thu, 10 Jul 2025 20:40:47 +0200 Subject: [PATCH 2/6] updated main file position --- .goreleaser.yaml | 2 +- README.md | 18 +++++++++++++++--- .../numscript.go => cmd/numscript/main.go | 0 3 files changed, 16 insertions(+), 4 deletions(-) rename internal/numscript/numscript.go => cmd/numscript/main.go (100%) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c5dc4792..dd1aa786 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,7 +16,7 @@ before: builds: - env: - CGO_ENABLED=0 - main: ./internal/numscript/numscript.go + main: ./cmd/numscript/main.go goos: - linux - windows diff --git a/README.md b/README.md index 76747bc1..5ca2b430 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,18 @@ The language server features include: - Detect document symbols - Go to definition -### Build locally -If you have the golang toolchain installed locally, you can run `go install ./internal/numscript/numscript.go` to build the cli from source, which you'll be able to run by executing the `numscript` command -Otherwise, you can download it from this repo's [releases](https://github.com/formancehq/numscript/releases) +### Installation + +You can install the `numscript` cli with one of the following ways: + +**Using curl** + +```sh +curl -sSf https://raw.githubusercontent.com/formancehq/numscript/refs/heads/main/install.sh | bash +``` + +**Using golang toolchain** + +```sh +go install github.com/formancehq/numscript/cmd/numscript.go@latest +``` diff --git a/internal/numscript/numscript.go b/cmd/numscript/main.go similarity index 100% rename from internal/numscript/numscript.go rename to cmd/numscript/main.go From 55d68fe4ea5f0d690114c9026df8e8d61f80ca64 Mon Sep 17 00:00:00 2001 From: ascandone Date: Thu, 10 Jul 2025 21:03:09 +0200 Subject: [PATCH 3/6] avoid requiring sudo --- install.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index ff418ec6..f2169dcd 100644 --- a/install.sh +++ b/install.sh @@ -54,10 +54,14 @@ else BIN="numscript" fi -sudo mv "$BIN" /usr/local/bin/ -chmod +x /usr/local/bin/"$BIN" + +INSTALL_PATH="$HOME/.local/bin" +mkdir -p "$INSTALL_PATH" + +mv "$BIN" "$INSTALL_PATH" +chmod +x "$INSTALL_PATH/$BIN" rm "$FILENAME" -echo "✅ Installed $BIN to /usr/local/bin" +echo "✅ Installed $BIN to $INSTALL_PATH" echo "🎉 Done!" From 82ffd4cfaa201c324b6211100acced468772132e Mon Sep 17 00:00:00 2001 From: ascandone Date: Thu, 10 Jul 2025 21:03:57 +0200 Subject: [PATCH 4/6] better tar command --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index f2169dcd..a9b69ef3 100644 --- a/install.sh +++ b/install.sh @@ -50,7 +50,7 @@ if [ "$PLATFORM" = "Windows" ]; then unzip "$FILENAME" BIN="numscript.exe" else - tar -xvf "$FILENAME" + tar -xf "$FILENAME" numscript BIN="numscript" fi From e2f83aa170ca5057e434ff309fe1da4ce2c045d3 Mon Sep 17 00:00:00 2001 From: ascandone Date: Thu, 10 Jul 2025 21:09:21 +0200 Subject: [PATCH 5/6] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ca2b430..c454c66e 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,5 @@ curl -sSf https://raw.githubusercontent.com/formancehq/numscript/refs/heads/main **Using golang toolchain** ```sh -go install github.com/formancehq/numscript/cmd/numscript.go@latest +go install github.com/formancehq/numscript/cmd/numscript@latest ``` From 5686c914d2f2ee821d59da76341fb920eb5e49bb Mon Sep 17 00:00:00 2001 From: ascandone Date: Thu, 10 Jul 2025 21:10:36 +0200 Subject: [PATCH 6/6] fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c454c66e..c0314f65 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ You can install the `numscript` cli with one of the following ways: **Using curl** ```sh -curl -sSf https://raw.githubusercontent.com/formancehq/numscript/refs/heads/main/install.sh | bash +curl -sSf https://raw.githubusercontent.com/formancehq/numscript/main/install.sh | bash ``` **Using golang toolchain**