detached 8569491

feat(cli): switch to go install for user-owned binary and easier updates

commit
8569491413cc56b2821873cff81f0bf23b7db4a1
author
bnema · · 2025-10-21 17:37 UTC
committer
bnema · · 2025-10-21 17:50 UTC
parent
11218e6
signature
unsigned
1 file · +14 -36
M install/post-boot/archup-cli.sh +14 -36
@@ -1,17 +1,15 @@
11 #!/bin/bash
2-# Build and install archup-cli from latest GitHub release
2+# Build and install archup-cli using go install
33
44 set -e
55
66 GITHUB_REPO="bnema/archup-cli"
7-INSTALL_DIR="/tmp/archup-cli-build"
8-BINARY_PATH="/usr/bin/archup"
97
108 echo "=== Installing archup-cli ==="
119
1210 # Check if Go is installed
1311 if ! command -v go &> /dev/null; then
14- echo "ERROR: Go is not installed. Cannot build archup-cli."
12+ echo "ERROR: Go is not installed. Cannot install archup-cli."
1513 exit 1
1614 fi
1715
@@ -20,49 +18,29 @@ echo "Fetching latest release from GitHub..."
2018 LATEST_RELEASE=$(curl -s "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
2119
2220 if [ -z "$LATEST_RELEASE" ]; then
23- echo "WARNING: No releases found, falling back to main branch"
24- DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/archive/refs/heads/main.tar.gz"
25- EXTRACT_DIR="archup-cli-main"
21+ echo "WARNING: No releases found, installing from main branch"
22+ VERSION="@latest"
2623 else
2724 echo "Latest release: $LATEST_RELEASE"
28- DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/archive/refs/tags/${LATEST_RELEASE}.tar.gz"
29- # Remove 'v' prefix if present for directory name
30- TAG_NAME="${LATEST_RELEASE#v}"
31- EXTRACT_DIR="archup-cli-${TAG_NAME}"
25+ VERSION="@${LATEST_RELEASE}"
3226 fi
3327
34-# Clean up any previous builds
35-rm -rf "$INSTALL_DIR"
36-mkdir -p "$INSTALL_DIR"
28+# Install using go install (installs to $GOBIN or $GOPATH/bin or ~/go/bin)
29+echo "Installing archup-cli ${VERSION}..."
30+go install "github.com/${GITHUB_REPO}${VERSION}"
3731
38-# Download source
39-echo "Downloading source from ${DOWNLOAD_URL}..."
40-curl -L "$DOWNLOAD_URL" -o "${INSTALL_DIR}/archup-cli.tar.gz"
41-
42-# Extract
43-echo "Extracting source..."
44-tar -xzf "${INSTALL_DIR}/archup-cli.tar.gz" -C "$INSTALL_DIR"
45-
46-# Find the extracted directory
47-cd "${INSTALL_DIR}/${EXTRACT_DIR}"
48-
49-# Build the binary
50-echo "Building archup-cli..."
51-go build -o archup .
52-
53-# Install to /usr/bin
54-echo "Installing to ${BINARY_PATH}..."
55-install -m 755 archup "$BINARY_PATH"
56-
57-# Cleanup
58-cd /
59-rm -rf "$INSTALL_DIR"
32+# Determine where the binary was installed
33+GOBIN="${GOBIN:-$(go env GOPATH)/bin}"
34+BINARY_PATH="${GOBIN}/archup-cli"
6035
6136 # Verify installation
6237 if [ -x "$BINARY_PATH" ]; then
6338 echo "✓ archup-cli installed successfully"
6439 echo " Location: $BINARY_PATH"
6540 echo " Version: $($BINARY_PATH --version 2>/dev/null || echo 'unknown')"
41+ echo ""
42+ echo "To update in the future, run:"
43+ echo " go install github.com/${GITHUB_REPO}@latest"
6644 else
6745 echo "ERROR: Installation failed"
6846 exit 1
@@ -1,17 +1,15 @@
1 #!/bin/bash1 #!/bin/bash
2-# Build and install archup-cli from latest GitHub release2+# Build and install archup-cli using go install
3 3
4 set -e4 set -e
5 5
6 GITHUB_REPO="bnema/archup-cli"6 GITHUB_REPO="bnema/archup-cli"
7-INSTALL_DIR="/tmp/archup-cli-build"
8-BINARY_PATH="/usr/bin/archup"
9 7
10 echo "=== Installing archup-cli ==="8 echo "=== Installing archup-cli ==="
11 9
12 # Check if Go is installed10 # Check if Go is installed
13 if ! command -v go &> /dev/null; then11 if ! command -v go &> /dev/null; then
14- echo "ERROR: Go is not installed. Cannot build archup-cli."12+ echo "ERROR: Go is not installed. Cannot install archup-cli."
15 exit 113 exit 1
16 fi14 fi
17 15
@@ -20,49 +18,29 @@ echo "Fetching latest release from GitHub..."
20 LATEST_RELEASE=$(curl -s "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')18 LATEST_RELEASE=$(curl -s "https://api.github.com/repos/${GITHUB_REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
21 19
22 if [ -z "$LATEST_RELEASE" ]; then20 if [ -z "$LATEST_RELEASE" ]; then
23- echo "WARNING: No releases found, falling back to main branch"21+ echo "WARNING: No releases found, installing from main branch"
24- DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/archive/refs/heads/main.tar.gz"22+ VERSION="@latest"
25- EXTRACT_DIR="archup-cli-main"
26 else23 else
27 echo "Latest release: $LATEST_RELEASE"24 echo "Latest release: $LATEST_RELEASE"
28- DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/archive/refs/tags/${LATEST_RELEASE}.tar.gz"25+ VERSION="@${LATEST_RELEASE}"
29- # Remove 'v' prefix if present for directory name
30- TAG_NAME="${LATEST_RELEASE#v}"
31- EXTRACT_DIR="archup-cli-${TAG_NAME}"
32 fi26 fi
33 27
34-# Clean up any previous builds28+# Install using go install (installs to $GOBIN or $GOPATH/bin or ~/go/bin)
35-rm -rf "$INSTALL_DIR"29+echo "Installing archup-cli ${VERSION}..."
36-mkdir -p "$INSTALL_DIR"30+go install "github.com/${GITHUB_REPO}${VERSION}"
37 31
38-# Download source32+# Determine where the binary was installed
39-echo "Downloading source from ${DOWNLOAD_URL}..."33+GOBIN="${GOBIN:-$(go env GOPATH)/bin}"
40-curl -L "$DOWNLOAD_URL" -o "${INSTALL_DIR}/archup-cli.tar.gz"34+BINARY_PATH="${GOBIN}/archup-cli"
41-
42-# Extract
43-echo "Extracting source..."
44-tar -xzf "${INSTALL_DIR}/archup-cli.tar.gz" -C "$INSTALL_DIR"
45-
46-# Find the extracted directory
47-cd "${INSTALL_DIR}/${EXTRACT_DIR}"
48-
49-# Build the binary
50-echo "Building archup-cli..."
51-go build -o archup .
52-
53-# Install to /usr/bin
54-echo "Installing to ${BINARY_PATH}..."
55-install -m 755 archup "$BINARY_PATH"
56-
57-# Cleanup
58-cd /
59-rm -rf "$INSTALL_DIR"
60 35
61 # Verify installation36 # Verify installation
62 if [ -x "$BINARY_PATH" ]; then37 if [ -x "$BINARY_PATH" ]; then
63 echo "✓ archup-cli installed successfully"38 echo "✓ archup-cli installed successfully"
64 echo " Location: $BINARY_PATH"39 echo " Location: $BINARY_PATH"
65 echo " Version: $($BINARY_PATH --version 2>/dev/null || echo 'unknown')"40 echo " Version: $($BINARY_PATH --version 2>/dev/null || echo 'unknown')"
41+ echo ""
42+ echo "To update in the future, run:"
43+ echo " go install github.com/${GITHUB_REPO}@latest"
66 else44 else
67 echo "ERROR: Installation failed"45 echo "ERROR: Installation failed"
68 exit 146 exit 1

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 0

    ↑↓ moveenter openesc close