From 421a429ed99cca957365106485da97e085b0f173 Mon Sep 17 00:00:00 2001 From: John McBride Date: Thu, 17 Aug 2023 11:50:37 -0600 Subject: [PATCH] feat: Add install instructions and script for pizza CLI (#26) Signed-off-by: John McBride --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++-------- install.sh | 48 +++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 11 deletions(-) create mode 100755 install.sh diff --git a/README.md b/README.md index ef3e0f4..56b5323 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,26 @@ -# 🍕 Pizza CLI - -This CLI can be used for all things OpenSauced! +
+
+ Open Sauced +

🍕 Pizza CLI 🍕

+ A Go command line interface for all things OpenSauced! +
+
+
+

+ GitHub code size in bytes + + GitHub issues + + + GitHub Release + + + Discord + + + Twitter + +

``` ❯ pizza @@ -25,17 +45,39 @@ 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 @@ -43,10 +85,20 @@ To lint, run `make lint`. To run tests, run `make test`. To build, run `make bui 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 `. 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`. diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..208c915 --- /dev/null +++ b/install.sh @@ -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 🍕"