Skip to content

Commit

Permalink
feat: Add install instructions and script for pizza CLI (#26)
Browse files Browse the repository at this point in the history
Signed-off-by: John McBride <[email protected]>
  • Loading branch information
jpmcb authored Aug 17, 2023
1 parent ec2b357 commit 421a429
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 11 deletions.
74 changes: 63 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# 🍕 Pizza CLI

This CLI can be used for all things OpenSauced!
<div align="center">
<br>
<img alt="Open Sauced" src="https://i.ibb.co/7jPXt0Z/logo1-92f1a87f.png" width="300px">
<h1>🍕 Pizza CLI 🍕</h1>
<strong>A Go command line interface for all things OpenSauced!</strong>
<br>
</div>
<br>
<p align="center">
<img src="https://img.shields.io/github/languages/code-size/open-sauced/pizza" alt="GitHub code size in bytes">
<a href="https://github.com/open-sauced/pizza/issues">
<img src="https://img.shields.io/github/issues/open-sauced/pizza" alt="GitHub issues">
</a>
<a href="https://github.com/open-sauced/api.opensauced.pizza/releases">
<img src="https://img.shields.io/github/v/release/open-sauced/pizza.svg?style=flat" alt="GitHub Release">
</a>
<a href="https://discord.gg/U2peSNf23P">
<img src="https://img.shields.io/discord/714698561081704529.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2" alt="Discord">
</a>
<a href="https://twitter.com/saucedopen">
<img src="https://img.shields.io/twitter/follow/saucedopen?label=Follow&style=social" alt="Twitter">
</a>
</p>

```
❯ pizza
Expand All @@ -25,28 +45,60 @@ Use "pizza [command] --help" for more information about a command.

---

### 🖥️ Local Development
### 📦 Install

You'll need a few tools to get started:
There are several methods for downloading and installing the `pizza` CLI:

- The [Go toolchain](https://go.dev/doc/install)
- [Docker](https://docs.docker.com/engine/install/) (for linting and other tooling)
- Make
#### Homebrew

To lint, run `make lint`. To run tests, run `make test`. To build, run `make build`.
```sh
brew install open-sauced/tap/pizza
```

#### Direct script install

```sh
curl -fsSL https://raw.githubusercontent.com/open-sauced/pizza-cli/main/install.sh | sh
```

This is a convenience script that can be downloaded from GitHub directly and
piped into `sh` for conveniently downloading the latest GitHub release of the
`pizza` CLI.

### 🏗️ Installation
Once download is completed, you can move the binary to a convenient location in
your system's `$PATH`.

> [!WARNING]
> It may not be advisable to pipe scripts from GitHub directly into
> a command line interpreter! If you do not fully trust the source, first
> download the script, inspect it manually to ensure its integrity, and then
> run it:
> ```sh
> curl -fsSL https://raw.githubusercontent.com/open-sauced/pizza-cli/main/install.sh > install.sh
> vim install.sh
> ./install.sh
> ```
#### Manual build and install
```
make install
```
This is a convenience target for building and dropping the pizza CLI into
This is a convenience `make` target for building and dropping the pizza CLI into
`/usr/local/bin/` (which requires `sudo` permissions).
Make sure you have that directory in your path: `export PATH="$PATH:/usr/local/bin"`.
Otherwise, you can build it manually with `make build` and `mv build/pizza <somewhere-in-your-path>`.

In the future, we will be dropping regular GitHub releases where you can easily
download and install pre-built binaries.

### 🖥️ Local Development

You'll need a few tools to get started:

- The [Go toolchain](https://go.dev/doc/install)
- [Docker](https://docs.docker.com/engine/install/) (for linting and other tooling)
- Make

To lint, run `make lint`. To run tests, run `make test`. To build, run `make build`.
48 changes: 48 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/sh

# This is a convenience script that can be downloaded from GitHub and
# piped into "sh" for conveniently downloading the latest GitHub release
# of the pizza CLI:
#
# curl -fsSL https://raw.githubusercontent.com/open-sauced/pizza-cli/main/install.sh | sh
#
# Warning: It may not be advisable to pipe scripts from GitHub directly into
# a command line interpreter! If you do not fully trust the source, first
# download the script, inspect it manually to ensure its integrity, and then
# run it:
#
# curl -fsSL https://raw.githubusercontent.com/open-sauced/pizza-cli/main/install.sh > install.sh
# vim install.sh
# ./install.sh

PIZZA_REPO="open-sauced/pizza-cli"
ARCH=""

# Detect architecture
case "$(uname -m)" in
x86_64) ARCH="x86_64" ;;
arm64) ARCH="arm64" ;;
*) echo "Unsupported architecture"; exit 1 ;;
esac

# Detect OS system type. Windows not supported.
case "$(uname -s)" in
Darwin) OSTYPE="darwin" ;;
*) OSTYPE="linux" ;;
esac

# Fetch download URL for the architecture from the GitHub API
ASSET_URL=$(curl -s https://api.github.com/repos/$PIZZA_REPO/releases/latest | \
grep -o "https:\/\/github\.com\/open-sauced\/pizza-cli\/releases\/download\/.*${OSTYPE}-${ARCH}.*")

if [ -z "$ASSET_URL" ]; then
echo "Could not find a binary for latest version of Pizza CLI release and architecture ${ARCH} on OS type ${OSTYPE}"
exit 1
fi

# Download and install
curl -L "${ASSET_URL}" -o ./pizza
chmod +x ./pizza

echo
echo "Download complete. Stay saucy 🍕"

0 comments on commit 421a429

Please sign in to comment.