Skip to content

Commit

Permalink
Adding Installation Script and Release Automation
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitbbhayani committed Oct 23, 2024
1 parent 371430f commit 4803504
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ go.work.sum
.idea/

# Generated binaries
dicedb-cli
dicedb-cli
dist/
37 changes: 37 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
release:
git tag 0.0.1
git push origin 0.0.1
goreleaser release --clean
24 changes: 9 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
59 changes: 59 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -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 ✓"

0 comments on commit 4803504

Please sign in to comment.