forked from MystenLabs/walrus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbump_sui_testnet_version.sh
More file actions
executable file
·131 lines (110 loc) · 3.36 KB
/
bump_sui_testnet_version.sh
File metadata and controls
executable file
·131 lines (110 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
# Copyright (c) Walrus Foundation
# SPDX-License-Identifier: Apache-2.0
#
# This script creates a Sui Testnet Version Bump PR
set -Eeuo pipefail
# Ensure required binaries are available
for cmd in cargo gh sui git; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: required command '$cmd' not found in PATH." >&2
exit 1
fi
done
# Check required params.
if [[ -z ${1:-} || $# -ne 1 ]]; then
echo "USAGE: bump_sui_testnet_version.sh <new-tag>"
exit 1
else
NEW_TAG="$1"
fi
# (Loose) sanity check on tag format.
if [[ ! "$NEW_TAG" =~ ^testnet-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Warning: NEW_TAG '$NEW_TAG' doesn't look like testnet-vX.Y.Z" >&2
fi
# Make sure GITHUB_ACTOR is set.
if [[ -z "${GITHUB_ACTOR:-}" ]]; then
GITHUB_ACTOR="$(git config user.name 2>/dev/null || echo github-actions[bot])"
fi
# Set up branch for changes.
STAMP="$(date +%Y%m%d%H%M%S)"
BRANCH="${GITHUB_ACTOR}/bump-sui-${NEW_TAG}-${STAMP}"
git checkout -b "$BRANCH"
# Allow recursive globs.
shopt -s globstar nullglob
# List of relevant TOML locations (globs allowed).
FILES=(
"contracts/**/Move.toml"
"docker/walrus-antithesis/sui_version.toml"
"Cargo.toml"
"testnet-contracts/**/Move.toml"
)
# Expand patterns into actual file paths.
TARGETS=()
for pat in "${FILES[@]}"; do
for f in $pat; do
[[ -f "$f" ]] && TARGETS+=("$f")
done
done
# Check if we found any targets.
if [[ ${#TARGETS[@]} -eq 0 ]]; then
echo "No matching files found for update."
exit 0
else
echo "Updating testnet tags in:"
printf ' - %s\n' "${TARGETS[@]}"
for f in "${TARGETS[@]}"; do
sed -i -E \
"s/(rev = \")testnet-v[0-9]+\.[0-9]+\.[0-9]+/\1${NEW_TAG}/g; \
s/(tag = \")testnet-v[0-9]+\.[0-9]+\.[0-9]+/\1${NEW_TAG}/g; \
s/(SUI_VERSION = \")testnet-v[0-9]+\.[0-9]+\.[0-9]+/\1${NEW_TAG}/g" "$f"
done
fi
# Update Cargo.lock files
echo "Running cargo check ..."
cargo check || true
# Find all directories that contain a Move.toml and generate Move.lock files.
echo "Regenerating Move.lock files..."
for toml in contracts/**/Move.toml testnet-contracts/**/Move.toml; do
if [[ -f "$toml" ]]; then
dir=$(dirname "$toml")
echo " -> building $dir"
(cd "$dir" && sui move build)
fi
done
# Staged all changes
echo "Staging all changed files..."
git add -u . ':!/.github/workflows'
# Commit, push, and create PR.
git config user.name "github-actions[bot]"
git config user.email \
"41898282+github-actions[bot]@users.noreply.github.com"
# Push branch
git commit -m "ci: bump Sui testnet version to ${NEW_TAG}"
git push -u origin "$BRANCH"
# Generate PR body
BODY="This PR updates the Sui testnet version to ${NEW_TAG}"
# Create PR
echo "Creating pull request..."
if PR_OUTPUT=$(gh pr create \
--base main \
--head "$BRANCH" \
--title "ci: bump Sui testnet version to ${NEW_TAG}" \
--reviewer "wbbradley,halfprice,liquid-helium,ebmifa" \
--body "$BODY" 2>&1); then
# Extract PR URL from output
if PR_URL=$(echo "$PR_OUTPUT" | grep -Eo 'https://github.com/[^ ]+'); then
echo "Successfully created PR: $PR_URL"
else
echo "Warning: PR created but could not extract URL from output:"
echo "$PR_OUTPUT"
PR_URL="(URL extraction failed)"
fi
else
echo "Error: Failed to create pull request:" >&2
echo "$PR_OUTPUT" >&2
exit 1
fi
# Setting the PR to auto merge
gh pr merge --auto --squash --delete-branch "$BRANCH"
echo "$PR_URL"