Skip to content

Commit 3b47793

Browse files
committed
feat(scripts): add gup support for Go binary updates
Add gup (github.com/nao1215/gup) as a package manager for Go tools, enabling automatic updates of all Go binaries installed via 'go install'. Changes: - scripts/auto_update.sh: Add detect_gup(), update_gup(), stats, CLI - cli_audit/package_managers.py: Add gup PackageManager, update Go hierarchy - catalog/gup.json: New catalog entry with go/github/brew install methods When gup is available, 'make upgrade-managed' now automatically updates all Go binaries. Falls back to manual instructions if gup is not installed.
1 parent dc3c10e commit 3b47793

3 files changed

Lines changed: 96 additions & 8 deletions

File tree

catalog/gup.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "gup",
3+
"install_method": "auto",
4+
"description": "Update Go binaries installed via 'go install' to their latest versions",
5+
"homepage": "https://github.com/nao1215/gup",
6+
"github_repo": "nao1215/gup",
7+
"binary_name": "gup",
8+
"version_flag": "version",
9+
"download_url_template": "https://github.com/nao1215/gup/releases/download/{version}/gup-{version}-linux-amd64.tar.gz",
10+
"arch_map": {
11+
"x86_64": "amd64",
12+
"aarch64": "arm64",
13+
"armv7l": "armv6"
14+
},
15+
"available_methods": [
16+
{
17+
"method": "go",
18+
"priority": 1,
19+
"config": {
20+
"package": "github.com/nao1215/gup"
21+
}
22+
},
23+
{
24+
"method": "github_release_binary",
25+
"priority": 2,
26+
"config": {
27+
"repo": "nao1215/gup",
28+
"asset_pattern": "gup-.*-linux-amd64.tar.gz"
29+
}
30+
},
31+
{
32+
"method": "brew",
33+
"priority": 3,
34+
"config": {
35+
"tap": "nao1215/tap",
36+
"package": "gup"
37+
}
38+
}
39+
],
40+
"requires": ["go"],
41+
"tags": ["go", "package-manager", "updater"]
42+
}

cli_audit/package_managers.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,15 @@ def get_install_command(self, package: str, version: str = "latest") -> tuple[st
180180
languages=("node", "javascript"),
181181
),
182182

183-
# Go package manager
183+
# Go package managers
184+
PackageManager(
185+
name="gup",
186+
display_name="gup",
187+
check_command=("gup", "version"),
188+
install_command_template=("go", "install", "{package}@latest"),
189+
category="vendor",
190+
languages=("go",),
191+
),
184192
PackageManager(
185193
name="go",
186194
display_name="go install",
@@ -311,7 +319,7 @@ def get_default_hierarchy(language: str) -> list[str]:
311319
"rust": ["rustup", "cargo"],
312320
"node": ["nvm", "npm"],
313321
"javascript": ["nvm", "npm", "yarn", "pnpm"],
314-
"go": ["go"],
322+
"go": ["gup", "go"],
315323
}
316324
return hierarchies.get(language, [])
317325

scripts/auto_update.sh

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ detect_go() {
8383
command -v go >/dev/null 2>&1
8484
}
8585

86+
detect_gup() {
87+
command -v gup >/dev/null 2>&1
88+
}
89+
8690
detect_gem() {
8791
command -v gem >/dev/null 2>&1
8892
}
@@ -357,7 +361,14 @@ update_go() {
357361
if ! detect_go; then return; fi
358362
log "Go: Updating installed binaries"
359363

360-
# Go doesn't have a built-in package manager for updating binaries
364+
# Use gup if available for automatic updates
365+
if detect_gup; then
366+
log "Go: Using gup to update all Go binaries"
367+
update_gup
368+
return
369+
fi
370+
371+
# Fallback: Go doesn't have a built-in package manager for updating binaries
361372
# List common go-installed tools and suggest updating
362373
local gobin gopath
363374
gobin="$(go env GOBIN 2>/dev/null || true)"
@@ -368,11 +379,25 @@ update_go() {
368379
fi
369380

370381
if [ -n "$gobin" ] && [ -d "$gobin" ]; then
371-
vlog "Go: Binaries in $gobin (manual upgrade needed: go install <package>@latest)"
372-
log "Go: Update via go install <package>@latest for each tool"
382+
vlog "Go: Binaries in $gobin"
383+
log "Go: Install gup for automatic updates: go install github.com/nao1215/gup@latest"
384+
log "Go: Or update manually via: go install <package>@latest for each tool"
373385
fi
374386

375-
log "Go: Manual updates required"
387+
log "Go: Manual updates required (install gup for automation)"
388+
}
389+
390+
update_gup() {
391+
if ! detect_gup; then return; fi
392+
log "Gup: Updating all Go binaries installed via 'go install'"
393+
394+
# Update gup itself first
395+
run_cmd "Gup: Self-update" go install github.com/nao1215/gup@latest
396+
397+
# Update all Go binaries
398+
run_cmd "Gup: Update all Go binaries" gup update
399+
400+
log "Gup: Complete"
376401
}
377402

378403
update_gem() {
@@ -521,6 +546,11 @@ get_manager_stats() {
521546
local gobin="$(go env GOBIN 2>/dev/null || echo "$(go env GOPATH 2>/dev/null)/bin")"
522547
pkg_count="$([ -d "$gobin" ] && ls -1 "$gobin" 2>/dev/null | wc -l | tr -d '[:space:]' || echo "0")"
523548
;;
549+
gup)
550+
location="$(command -v gup 2>/dev/null || echo "N/A")"
551+
version="$(gup version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown")"
552+
pkg_count="$(gup list 2>/dev/null | tail -n +2 | wc -l | tr -d '[:space:]' || echo "0")"
553+
;;
524554
gem)
525555
location="$(command -v gem 2>/dev/null || echo "N/A")"
526556
version="$(gem --version 2>/dev/null || echo "unknown")"
@@ -667,6 +697,9 @@ show_manager_update_hint() {
667697
go)
668698
echo "$mgr: Download latest from https://go.dev/dl/ and install"
669699
;;
700+
gup)
701+
echo "$mgr: Run 'go install github.com/nao1215/gup@latest && gup update' or './scripts/auto_update.sh gup'"
702+
;;
670703
gem)
671704
echo "$mgr: Run 'gem update --system' or './scripts/auto_update.sh gem'"
672705
;;
@@ -698,7 +731,7 @@ show_detected() {
698731
log "Detecting installed package managers with scope information..."
699732
echo ""
700733

701-
local all_managers=(apt snap brew flatpak cargo rustup uv pipx pip npm pnpm yarn go gem composer poetry conda mamba bundler jspm nuget gcloud az)
734+
local all_managers=(apt snap brew flatpak cargo rustup uv pipx pip npm pnpm yarn go gup gem composer poetry conda mamba bundler jspm nuget gcloud az)
702735
local found_managers=0
703736
local found_scopes=0
704737
local outdated_managers=()
@@ -904,7 +937,8 @@ Commands:
904937
npm Update only NPM packages
905938
pnpm Update only PNPM packages
906939
yarn Update only Yarn packages
907-
go Show Go update instructions
940+
go Update Go binaries (uses gup if available)
941+
gup Update all Go binaries via gup (github.com/nao1215/gup)
908942
gem Update only RubyGems packages
909943
snap Update only Snap packages
910944
flatpak Update only Flatpak packages
@@ -1012,6 +1046,10 @@ while [[ $# -gt 0 ]]; do
10121046
update_go
10131047
exit 0
10141048
;;
1049+
gup)
1050+
update_gup
1051+
exit 0
1052+
;;
10151053
gem)
10161054
update_gem
10171055
exit 0

0 commit comments

Comments
 (0)