Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/bastin_version-upgrade-script.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- Bash script for automating the version upgrade process.
79 changes: 79 additions & 0 deletions hack/upgrade-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env bash
set -euo pipefail

# ====== config ======
OLD="OffchainLabs/prysm/v6"
NEW="OffchainLabs/prysm/v7"

# files by extension (recursive)
EXTENSIONS=("bazel" "go" "proto")

# explicit files (relative to project root)
EXPLICIT_FILES=(
"hack/update-mockgen.sh"
"hack/update-go-pbs.sh"
"go.mod"
".deepsource.toml"
)

# commands to run at the end, in order
COMMANDS=(
'bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%prysm_deps -prune=true'
'go mod tidy && go get ./...'
'bazel clean --expunge --async'
'./hack/update-go-pbs.sh'
'./hack/update-go-ssz.sh'
'go build ./... && bazel build //cmd/beacon-chain //cmd/validator'
)
# ====================

# Detect BSD vs GNU sed (macOS vs Linux)
if sed --version >/dev/null 2>&1; then
SED_INPLACE=("sed" "-i")
else
# macOS / BSD sed needs an empty string after -i
SED_INPLACE=("sed" "-i" "")
fi

escape_sed() {
# escape / in pattern and replacement so sed doesn't choke
printf '%s' "$1" | sed 's/[\/&]/\\&/g'
}

OLD_ESCAPED=$(escape_sed "$OLD")
NEW_ESCAPED=$(escape_sed "$NEW")

############################################
# 1) walk directory by extensions
############################################
for ext in "${EXTENSIONS[@]}"; do
while IFS= read -r -d '' file; do
"${SED_INPLACE[@]}" "s/${OLD_ESCAPED}/${NEW_ESCAPED}/g" "$file"
echo "updated (by ext): $file"
done < <(find . -type f -name "*.${ext}" -print0)
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The script searches the entire directory tree including potentially large directories like node_modules, .git, or build artifacts. Consider excluding common directories that shouldn't contain Prysm imports, e.g., find . -type f -name \"*.${ext}\" ! -path \"*/node_modules/*\" ! -path \"*/.git/*\" ! -path \"*/bazel-*/*\" -print0.

Suggested change
done < <(find . -type f -name "*.${ext}" -print0)
done < <(find . -type f -name "*.${ext}" \
! -path "*/node_modules/*" \
! -path "*/.git/*" \
! -path "*/bazel-*/*" \
-print0)

Copilot uses AI. Check for mistakes.
done

############################################
# 2) specific files
############################################
for f in "${EXPLICIT_FILES[@]}"; do
if [[ -f "$f" ]]; then
"${SED_INPLACE[@]}" "s/${OLD_ESCAPED}/${NEW_ESCAPED}/g" "$f"
echo "updated (explicit): $f"
else
echo "warn: explicit file not found: $f" >&2
fi
done

############################################
# 3) run commands in order
############################################
for cmd in "${COMMANDS[@]}"; do
echo "==> running: $cmd"
# use bash -c so we can have && in commands
bash -c "$cmd"
echo "==> done: $cmd"
done

echo
echo "✅ version upgrade was successful."
Loading