Files
upstream-centrifugo/misc/scripts/update-deps.sh
upstream-mirror b352a9a30d
Some checks failed
test / Lint (push) Failing after 3s
test / Test with Go 1.26.8 (push) Failing after 2s
snapshot of https://github.com/centrifugal/centrifugo.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 01:17:21 +05:00

57 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Update all Go module dependencies.
#
# Usage:
# ./scripts/update-deps.sh # minor/patch updates only
# ./scripts/update-deps.sh --major # also apply major version updates
set -euo pipefail
cd "$(pwd)"
pwd
# Packages to exclude from automatic updates (updated manually).
EXCLUDE=(
"github.com/centrifugal/centrifuge"
"github.com/mailru/easyjson"
)
# Record current versions of excluded packages.
SAVED=()
for pkg in "${EXCLUDE[@]}"; do
ver=$(grep "^[[:space:]]*${pkg} " go.mod | awk '{print $2}')
if [[ -n "$ver" ]]; then
SAVED+=("${pkg}@${ver}")
fi
done
echo "==> Updating all dependencies to latest minor/patch versions..."
go get -u ./...
# Restore excluded packages to their original versions.
for entry in "${SAVED[@]}"; do
echo "==> Pinning $entry (excluded from update)"
go get "$entry"
done
echo "==> Running go mod tidy..."
go mod tidy
if [[ "${1:-}" == "--major" ]]; then
if ! command -v gomajor &>/dev/null; then
echo "gomajor not found, installing..."
go install github.com/icholy/gomajor@latest
fi
echo "==> Checking for major version updates..."
gomajor list
echo ""
read -rp "Apply all major version updates? [y/N] " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
gomajor get -a ./...
echo "==> Running go mod tidy after major updates..."
go mod tidy
fi
fi
echo "==> Done. Review changes with: git diff go.mod"