Skip to content

Commit

Permalink
feat(install): Use Script Install (#163)
Browse files Browse the repository at this point in the history
* feat(install): Use Script Install

* change README
  • Loading branch information
go-to-k committed Dec 7, 2023
1 parent 7fcdbff commit 4cd3bd8
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 9 deletions.
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,36 @@ Also this tool can support output results **as a CSV file.**
## Install

- Homebrew
```sh

```bash
brew install go-to-k/tap/lamver
```

- Linux, Darwin (macOS) and Windows

```bash
curl -fsSL https://raw.githubusercontent.com/go-to-k/lamver/main/install.sh | sh
lamver -h
# To install a specific version of lamver
# e.g. version 0.8.0
curl -fsSL https://raw.githubusercontent.com/go-to-k/lamver/main/install.sh | sh -s "v0.8.0"
lamver -h
```

- Binary
- [Releases](https://github.com/go-to-k/lamver/releases)
- Git Clone and install(for developers)
```sh

```bash
git clone https://github.com/go-to-k/lamver.git
cd lamver
make install
```

## How to use
```sh

```bash
lamver [-p <profile>] [-r <default region>] [-o <output file path>] [-k <keyword for function name>]
```
Expand All @@ -57,7 +73,7 @@ Also this tool can support output results **as a CSV file.**
### Enter `lamver`
```sh
```bash
❯ lamver
```
Expand All @@ -69,7 +85,7 @@ You can specify `-k, --keyword` option. This is a keyword for **function name fi
### Choose regions
```sh
```bash
? Select regions you want to search.
[Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
[x] ap-northeast-1
Expand All @@ -93,7 +109,7 @@ You can specify `-k, --keyword` option. This is a keyword for **function name fi
### Choose runtime values
```sh
```bash
? Select runtime values you want to search.
[Use arrows to move, space to select, <right> to all, <left> to none, type to filter]
> [ ] dotnet6
Expand Down Expand Up @@ -142,13 +158,13 @@ You can search function names in a **case-insensitive**.
This phase is skipped if you specify `-k` option.
```sh
```bash
Filter a keyword of function names(case-insensitive): test-goto
```
### The result will be output
```sh
```bash
+--------------+----------------+----------------------+------------------------------+
| RUNTIME | REGION | FUNCTIONNAME | LASTMODIFIED |
+--------------+----------------+----------------------+------------------------------+
Expand Down Expand Up @@ -181,6 +197,6 @@ By default, results are output as table format on the screen.
If you add `-o` option, then results can be output **as a CSV file**.
```sh
```bash
lamver -o ./result.csv
```
87 changes: 87 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

# This script automates the installation of the lamver tool.
# It checks for the specified version (or fetches the latest one),
# downloads the binary, and installs it on the system.

# Check for required tools: curl and tar.
# These tools are necessary for downloading and extracting the lamver binary.
if ! command -v curl &>/dev/null; then
echo "curl could not be found"
exit 1
fi

if ! command -v tar &>/dev/null; then
echo "tar could not be found"
exit 1
fi

# Determine the version of lamver to install.
# If no version is specified as a command line argument, fetch the latest version.
if [ -z "$1" ]; then
VERSION=$(curl -s https://api.github.com/repos/go-to-k/lamver/releases/latest | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo "Failed to fetch the latest version"
exit 1
fi
else
VERSION=$1
fi

# Normalize the version string by removing any leading 'v'.
VERSION=${VERSION#v}

# Detect the architecture of the current system.
# This script supports x86_64, arm64, and i386 architectures.
ARCH=$(uname -m)
case $ARCH in
x86_64 | amd64) ARCH="x86_64" ;;
arm64 | aarch64) ARCH="arm64" ;;
i386 | i686) ARCH="i386" ;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac

# Detect the operating system (OS) of the current system.
# This script supports Linux, Darwin (macOS) and Windows operating systems.
OS=$(uname -s)
case $OS in
Linux) OS="Linux" ;;
Darwin) OS="Darwin" ;;
MINGW* | MSYS* | CYGWIN*) OS="Windows" ;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac

# Construct the download URL for the lamver binary based on the version, OS, and architecture.
FILE_NAME="lamver_${VERSION}_${OS}_${ARCH}.tar.gz"
URL="https://github.com/go-to-k/lamver/releases/download/v${VERSION}/${FILE_NAME}"

# Download the lamver binary.
echo "Downloading lamver..."
if ! curl -L -o "$FILE_NAME" "$URL"; then
echo "Failed to download lamver"
exit 1
fi

# Install lamver.
# This involves extracting the binary and moving it to /usr/local/bin.
echo "Installing lamver..."
if ! tar -xzf "$FILE_NAME"; then
echo "Failed to extract lamver"
exit 1
fi
if ! sudo mv lamver /usr/local/bin/lamver; then
echo "Failed to install lamver"
exit 1
fi

# Clean up by removing the downloaded tar file.
rm "$FILE_NAME"

echo "lamver installation complete."
echo "Run 'lamver -h' to see how to use lamver."

0 comments on commit 4cd3bd8

Please sign in to comment.