From 437708dae1cf9333044e605ec7b7ee38c05ebb81 Mon Sep 17 00:00:00 2001 From: Sid Edwards Date: Thu, 24 Oct 2024 05:31:33 -0600 Subject: [PATCH] chore(release): add install script and update README - Add install.sh script to simplify installation - Update README with instructions for quick install - Add downloads section with links to latest binary releases - Improve formatting and structure of README BREAKING CHANGE: The manual installation instructions have changed. Users should now use the quick install script or download the latest binary release. --- .github/workflows/release.yml | 8 +++- README.md | 21 +++++++--- install.sh | 0 scripts/install.sh | 77 +++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 install.sh create mode 100644 scripts/install.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0122352..14511c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,7 +49,12 @@ jobs: body: | ${{ steps.release_notes.outputs.result }} - ## Downloads + ## Quick Install + ```bash + curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/main/scripts/install.sh | bash + ``` + + ## Manual Downloads - [macOS ARM64 (M1/M2)](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/auto-commit-darwin-arm64) - [macOS Intel](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/auto-commit-darwin-x64) - [Windows](https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/auto-commit-windows-x64.exe) @@ -67,3 +72,4 @@ jobs: dist/auto-commit-darwin-x64 dist/auto-commit-windows-x64.exe dist/auto-commit-linux-x64 + scripts/install.sh diff --git a/README.md b/README.md index 72003ff..7ee57a0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,18 @@ Automatically generate git commit messages using Claude 3 Haiku. Analyzes your s ## Installation -### Option 1: Pre-built Binary +### Option 1: Quick Install (macOS/Linux) + +```bash +curl -fsSL https://raw.githubusercontent.com/sidedwards/auto-commit/main/scripts/install.sh | bash +``` + +This will: +- Download the appropriate binary for your system +- Add it to your PATH +- Make it executable + +### Option 2: Manual Installation 1. Download the latest release for your platform from [GitHub Releases](https://github.com/sidedwards/auto-commit/releases) 2. Move to a location in your PATH: @@ -37,7 +48,7 @@ sudo chmod +x /usr/local/bin/auto-commit move auto-commit-windows-x64.exe C:\Windows\System32\auto-commit.exe ``` -### Option 2: Install from Source +### Option 3: Install from Source ````bash # Install Deno @@ -52,12 +63,12 @@ deno task install ### Updating ```bash +# If installed with quick install or manual binary +curl -fsSL https://raw.githubusercontent.com/sidedwards/auto-commit/main/scripts/install.sh | bash + # If installed from source cd auto-commit deno task update - -# If using pre-built binary -# Download the latest release and follow installation steps above ``` ## Usage diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e69de29 diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..f0608bc --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -e + +main() { + BIN_DIR=${BIN_DIR-"$HOME/.bin"} + mkdir -p $BIN_DIR + + case $SHELL in + */zsh) + PROFILE=$HOME/.zshrc + PREF_SHELL=zsh + ;; + */bash) + PROFILE=$HOME/.bashrc + PREF_SHELL=bash + ;; + */fish) + PROFILE=$HOME/.config/fish/config.fish + PREF_SHELL=fish + ;; + */ash) + PROFILE=$HOME/.profile + PREF_SHELL=ash + ;; + *) + echo "could not detect shell, manually add ${BIN_DIR} to your PATH." + exit 1 + esac + + if [[ ":$PATH:" != *":${BIN_DIR}:"* ]]; then + echo >> $PROFILE && echo "export PATH=\"\$PATH:$BIN_DIR\"" >> $PROFILE + fi + + PLATFORM="$(uname -s)" + case $PLATFORM in + Linux) + SUFFIX="linux-x64" + ;; + Darwin) + ARCH="$(uname -m)" + if [ "${ARCH}" = "arm64" ]; then + SUFFIX="darwin-arm64" + else + SUFFIX="darwin-x64" + fi + ;; + *) + err "unsupported platform: $PLATFORM" + ;; + esac + + BINARY_URL="https://github.com/sidedwards/auto-commit/releases/latest/download/auto-commit-${SUFFIX}" + if [ "$PLATFORM" = "MINGW"* ] || [ "$PLATFORM" = "MSYS"* ] || [ "$PLATFORM" = "CYGWIN"* ]; then + BINARY_URL="https://github.com/sidedwards/auto-commit/releases/latest/download/auto-commit-windows-x64.exe" + fi + + echo "Downloading latest auto-commit binary..." + ensure curl -L "$BINARY_URL" -o "$BIN_DIR/auto-commit" + chmod +x "$BIN_DIR/auto-commit" + + echo "auto-commit installed successfully!" + echo "Run 'auto-commit --help' to get started" +} + +# Run a command that should never fail. If the command fails execution +# will immediately terminate with an error showing the failing +# command. +ensure() { + if ! "$@"; then err "command failed: $*"; fi +} + +err() { + echo "$*" >&2 + exit 1 +} + +main "$@" || exit 1