Skip to content

Commit

Permalink
chore: install script and docs
Browse files Browse the repository at this point in the history
Set a installation script and improve the documentation.
  • Loading branch information
faabiosr committed May 28, 2024
1 parent 7e0fda1 commit 9011d8a
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- name: unshallow
run: git fetch --prune --unshallow

- name: shellcheck
run: shellcheck *.sh

- name: golanci-linter
uses: golangci/golangci-lint-action@v4
with:
Expand Down
43 changes: 33 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,48 @@
# LB - (Lambda) Layer Balancer
# lb

[![Build Status](https://img.shields.io/github/actions/workflow/status/faabiosr/lb/test.yaml?logo=github&style=flat-square)](https://github.com/faabiosr/lb/actions?query=workflow:test)
[![Codecov branch](https://img.shields.io/codecov/c/github/faabiosr/lb/master.svg?style=flat-square)](https://codecov.io/gh/faabiosr/lb)
[![Go Report Card](https://goreportcard.com/badge/github.com/faabiosr/lb?style=flat-square)](https://goreportcard.com/report/github.com/faabiosr/lb)
[![Release](https://img.shields.io/github/v/release/faabiosr/lb?display_name=tag&style=flat-square)](https://github.com/faabiosr/lb/releases)
[![License](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://github.com/faabiosr/lb/blob/master/LICENSE)

Balance your AWS lambda layers across regions.
## :tada: Overview
`lb` lets you balance your AWS lambda layers across regions.

## Installation
## :relaxed: Motivation
Managing AWS lambda layer across regions is difficult, because each new layer deployment will increment the version automatically, and if you need to introduce a new region, the result will be different versions.

### Linux (apt)
## :dart: Installation

### Unix-like

#### Manual installation
```sh
# by default will install into ~/.local/bin folder.
curl -sSL https://raw.githubusercontent.com/faabiosr/lb/main/install.sh | bash

# install into /usr/local/bin
curl -sSL https://raw.githubusercontent.com/faabiosr/lb/main/install.sh | sudo INSTALL_PATH=/usr/local/bin bash
```

### go
```sh
curl -LO https://github.com/faabiosr/lb/releases/download/v1.0.0/lb_1.0.0_linux_x86_64.deb
sudo apt install -f ./lb_1.0.0_linux_x86_64.deb
go install github.com/faabiosr/lb@latest
```

## Usage
[![asciicast](https://asciinema.org/a/658749.svg)](https://asciinema.org/a/658749)
## :gem: Usage

### Verify the versions deployed across regions
```sh
lb verify --regions 'us-east-1,eu-central-1,sa-east-1' my-layer
```

### Bump all regions with the latest version
```sh
lb bump --regions 'us-east-1,eu-central-1,sa-east-1' my-layer
```

## Development
## :toolbox: Development

### Requirements

Expand All @@ -35,6 +58,6 @@ Please run the make target below to see the provided targets.
$ make help
```

## License
## :page_with_curl: License

This project is released under the MIT licence. See [LICENSE](https://github.com/faabiosr/lb/blob/master/LICENSE) for more details.
56 changes: 56 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
# Install `lb`

function main {
local p="install: error:"
local ARCH=""
local OS=""
local VERSION=""

# check that required one of the commands are installed before doing anything.
if command -v curl &> /dev/null; then
cmd="curl -sSL"
elif command -v wget &> /dev/null; then
cmd="wget -qO -"
else
echo "${p} neither curl nor wget was found, please install of them and try again!"
exit 1
fi

# Get the latest version
VERSION=$(${cmd} "https://api.github.com/repos/faabiosr/lb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)

if [ -z "${VERSION}" ]; then
echo "${p} failed to get the latest version, please check your network connection and try again!"
exit 1
fi

echo "installing lb v${VERSION} ..."

# Check if the OS is supported
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
if [ "${OS}" = "darwin" ]; then
OS="macos"
fi

ARCH=$(uname -m)
if [ "${ARCH}" = "arm64" ]; then
ARCH="aarch64"
fi

local FILENAME="lb_${VERSION}_${OS}_${ARCH}"
local INSTALL_PATH="${INSTALL_PATH:-${HOME}/.local/bin}"

echo "https://github.com/faabiosr/lb/releases/download/v${VERSION}/${TAR_FILE}"
echo "installation path: ${INSTALL_PATH}"

mkdir -p "${INSTALL_PATH}" >/dev/null 2>&1 || { >&2 echo "${p} failed to create ${INSTALL_PATH} directory, please check your sudo permissions and try again!"; exit 1; }


${cmd} "https://github.com/faabiosr/lb/releases/download/v${VERSION}/${FILENAME}.tar.gz" \
| tar -xzvf - -C "${INSTALL_PATH}" "${FILENAME}/lb" --strip-components=1

echo "lb installed successfully!"
}

main "$@"

0 comments on commit 9011d8a

Please sign in to comment.