Skip to content

Add a one-line install script - #103

Merged
jonhadfield merged 2 commits into
mainfrom
feat/one-line-install
Sep 13, 2026
Merged

jonhadfield merged 2 commits into
mainfrom
feat/one-line-install

Conversation

@jonhadfield

Copy link
Copy Markdown
Owner
curl -fsSL https://raw.githubusercontent.com/jonhadfield/sn-cli/main/install.sh | sh

The README previously offered a multi-line case statement for picking the right archive, which is awkward to paste and easy to get wrong.

What the script does

  • Resolves the latest tag from the release redirect rather than the API, which is rate limited for unauthenticated callers
  • Picks the archive matching uname -s / uname -m, including the single universal darwin build and the Linux, FreeBSD and OpenBSD archives
  • Verifies the download against the published checksums before unpacking it
  • Installs to /usr/local/bin, overridable with BIN_DIR; VERSION pins a release
  • Clears the macOS quarantine flag, since these binaries are unsigned

On sudo

sudo is used only for the final install step, and only when the destination is not already writable — rather than piping the whole script into sudo sh. So the download, checksum verification and unpacking all run as you, and root is used for one install command.

If you would rather not pipe to a shell at all, install.sh is in the repository to read first, and the homebrew and manual-download routes are unchanged.

Verified

Each of these was actually run, not assumed:

case result
normal install installs, reports 0.5.1-b1da3fb
piped from stdin, as curl | sh does works
VERSION=0.5.0 installs 0.5.0
non-existent version exits 1, installs nothing
checksums unavailable exits 1, installs nothing
corrupted archive checksum mismatch, exits 1, installs nothing

🤖 Generated with Claude Code

https://claude.ai/code/session_01YKSZwABnkoJTMcpUhFife3

  curl -fsSL https://raw.githubusercontent.com/jonhadfield/sn-cli/main/install.sh | sh

The README previously offered a multi-line case statement for picking the
right archive, which is awkward to paste and easy to get wrong.

install.sh resolves the latest tag from the release redirect rather than
the API, which is rate limited for unauthenticated callers, picks the
archive matching uname, verifies it against the published checksums
before unpacking, and installs to /usr/local/bin. BIN_DIR and VERSION
override the destination and the release.

sudo is used only for the final install step, and only when the
destination is not already writable, rather than running the whole script
as root. On darwin it clears the quarantine flag, since these binaries
are unsigned.

Verified: install, piped from stdin as curl would, pinned VERSION,
non-existent version, missing checksums, and a corrupted archive. Each
failure exits non-zero and installs nothing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YKSZwABnkoJTMcpUhFife3
Copilot AI lite review requested due to automatic review settings September 13, 2026 20:51
@codacy-production

codacy-production Bot commented Sep 13, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation +0.00% coverage variation (-1.00%)
Diff coverage diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (b1da3fb) 9319 755 8.10%
Head commit (991a002) 9319 (+0) 755 (+0) 8.10% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#103) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The installer has confirmed portability/behavior bugs (BSD mktemp usage and incorrect sudo escalation for user-creatable BIN_DIR paths) that can break installs or create root-owned directories in user homes.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds a single-file POSIX sh installer to streamline installing sn-cli from GitHub Releases, and updates the README to document the one-liner install path alongside the existing Homebrew/manual options.

Changes:

  • Document a curl | sh one-liner install flow in README.md, including BIN_DIR and VERSION overrides.
  • Add install.sh that selects the correct release archive, verifies SHA-256 checksums, unpacks sn, clears macOS quarantine, and installs to BIN_DIR.
File summaries
File Description
README.md Adds one-line installer instructions and environment-variable overrides.
install.sh Introduces a platform-aware, checksum-verifying installer script for sn-cli.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread install.sh

base="https://github.com/$REPO/releases/download/$version"

tmp="$(mktemp -d)"
Comment thread install.sh
Comment on lines +104 to +113
sudo=""
if [ ! -d "$BIN_DIR" ] || [ ! -w "$BIN_DIR" ]; then
if [ "$(id -u)" -ne 0 ]; then
command -v sudo >/dev/null 2>&1 || fail "$BIN_DIR is not writable and sudo is not available"
sudo="sudo"
fi
fi

$sudo mkdir -p "$BIN_DIR"
$sudo install -m 755 "$tmp/sn" "$BIN_DIR/sn" || fail "failed to install into $BIN_DIR"
Codacy's markdownlint flags the curl commands as over 80 columns. Being a
single pasteable line is the point of them, and the raw.githubusercontent
URL cannot be shortened, so wrapping would break the feature rather than
improve the file.

Scoped to that block rather than disabling MD013 for the README, though
note 20 lines here already exceed the limit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YKSZwABnkoJTMcpUhFife3
@jonhadfield
jonhadfield merged commit fbbb457 into main Sep 13, 2026
10 checks passed
@jonhadfield
jonhadfield deleted the feat/one-line-install branch September 13, 2026 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants