diff --git a/.gitignore b/.gitignore index cd7b67d..39e2581 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ go.work.sum .idea/ # Generated binaries -dicedb-cli \ No newline at end of file +dicedb-cli +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..ff6a254 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,37 @@ +version: 2 + +project_name: dicedb-cli +before: + hooks: + - go mod tidy + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm + - arm64 + binary: dicedb-cli + +archives: + - format: tar.gz + name_template: "{{ .ProjectName }}_{{ .Version }}_{{ tolower .Os }}_{{ tolower .Arch }}" + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +checksum: + name_template: "checksums.txt" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e7bcc4 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +release: + git tag 0.0.1 + git push origin 0.0.1 + goreleaser release --clean diff --git a/README.md b/README.md index 116d030..addac70 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,12 @@ -# DiceDB CLI Client - -A command-line interface client for [DiceDB](https://dicedb.io). -## Table of Contents - -- [Features](#features) -- [Prerequisites](#prerequisites) -- [Installation](#installation) -- [Usage](#usage) - - [Basic Commands](#basic-commands) - - [Watch Commands](#watch-commands) -- [Command Autocompletion](#command-autocompletion) -- [For Developers](#for-developers) - - [Contributing](#contributing) -- [License](#license) +# DiceDB CLI + +A command-line interface for [DiceDB](https://dicedb.io). + +## Get Started + +```sh +curl -sL https://raw.githubusercontent.com/DiceDB/dicedb-cli/refs/heads/master/install.sh | sh +``` ## Features diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..925e4f4 --- /dev/null +++ b/install.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env sh +set -e + +REPO="DiceDB/dicedb-cli" +LATEST_RELEASE=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/') + +# Detect the operating system and architecture +OS=$(uname -s) +ARCH=$(uname -m) + +# Convert OS/ARCH to the naming convention used in releases +case $OS in + Linux) OS="linux" ;; + Darwin) OS="darwin" ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) OS="windows" ;; + *) echo "OS not supported"; exit 1 ;; +esac + +case $ARCH in + x86_64) ARCH="amd64" ;; + arm64|aarch64) ARCH="arm64" ;; + *) echo "Architecture not supported"; exit 1 ;; +esac + +BINARY="dicedb-cli_${LATEST_RELEASE}_${OS}_${ARCH}.tar.gz" +URL="https://github.com/$REPO/releases/download/$LATEST_RELEASE/$BINARY" + +echo "Downloading $BINARY..." +curl -L $URL -o /tmp/$BINARY + +# Extract and move to /usr/local/bin +tar -xzf /tmp/$BINARY -C /tmp +chmod 777 /tmp/dicedb-cli + +DICEDB_DIR=/usr/local/dicedb +DICEDB_BIN_DIR=$DICEDB_DIR/bin + +if [ ! -d "$DICEDB_DIR" ]; then + sudo mkdir -p $DICEDB_DIR +fi + +if [ ! -d "$DICEDB_BIN_DIR" ]; then + sudo mkdir -p $DICEDB_BIN_DIR + sudo chmod 777 $DICEDB_BIN_DIR +fi + +mv /tmp/dicedb-cli $DICEDB_BIN_DIR +sudo ln -sf $DICEDB_BIN_DIR/dicedb-cli /usr/local/bin/dicedb-cli + +echo "\n +██████╗ ██╗ ██████╗███████╗██████╗ ██████╗ +██╔══██╗██║██╔════╝██╔════╝██╔══██╗██╔══██╗ +██║ ██║██║██║ █████╗ ██║ ██║██████╔╝ +██║ ██║██║██║ ██╔══╝ ██║ ██║██╔══██╗ +██████╔╝██║╚██████╗███████╗██████╔╝██████╔╝ +╚═════╝ ╚═╝ ╚═════╝╚══════╝╚═════╝ ╚═════╝ +" +echo "> if you get 'command not found' error, add '/usr/local/bin' to your 'PATH' variable." +echo "\nDiceDB CLI installation complete ✓"