diff --git a/README.md b/README.md index ecb3ceb..b9c18cb 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,12 @@ Regardless of how you obtain your binary of choice, include it in your `$PATH` a ### Pre-built binaries The [releases](https://forge.karnov.club/spadinastan/spud/releases) page contains pre-built binaries that can be downloaded. These are built on tag-push. + +The latest version can be installed via: + +``` +curl https://forge.karnov.club/spadinastan/spud/raw/branch/main/install.sh | bash +``` + +To pull a specific version, supply a `$SPUD_VERSION` that corresponds to an existing release tag, and to control where +the binary is unpacked and installed, supply `$SPUD_ROOT`. diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..e384c1d --- /dev/null +++ b/install.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +############################################################################### +# +# Installation script +# +# This pulls the latest version (or the tag specified by $SPUD_VERSION) from +# the source repository, unpacks it and installs it at $SPUD_ROOT (defaults to +# ~/.local/bin). +# +##############################################################################W + +TMP_ROOT=$(mktemp -d) +DST_ROOT="${SPUD_ROOT:-$HOME/.local/bin}" + +BIN_ARCH="x64" +BIN_VERSION="${SPUD_VERSION:-latest}" + +ARCHIVE_NAME="$BIN_ARCH-build.zip" + +echo "Downloading spud ($BIN_VERSION) and extracting to $DST_ROOT" + +curl \ + --output "$TMP_ROOT/$ARCHIVE_NAME" \ + --fail \ + "https://forge.karnov.club/spadinastan/spud/releases/download/$BIN_VERSION/$ARCHIVE_NAME" + +if [[ ! -f "$TMP_ROOT/$ARCHIVE_NAME" ]]; then + echo "❌ Failed to download spud@$BIN_VERSION from repository." + exit 1; + +fi + +unzip "$TMP_ROOT/$ARCHIVE_NAME" -d "$TMP_ROOT" + +cp "$TMP_ROOT/spud" "$DST_ROOT" +chmod +x "$DST_ROOT/spud" + +echo "📦 Installed to $DST_ROOT, make sure that it is in your PATH."