forked from coinbase/agentkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion_phase_3.sh
More file actions
executable file
·76 lines (63 loc) · 1.89 KB
/
Copy pathversion_phase_3.sh
File metadata and controls
executable file
·76 lines (63 loc) · 1.89 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
#!/bin/bash
# Tag every package
cd "$(dirname "$0")"
# Check if --prod flag is set
PROD_MODE=false
for arg in "$@"; do
if [ "$arg" = "--prod" ]; then
PROD_MODE=true
break
fi
done
# Create a temporary file
TEMP_FILE=$(mktemp)
trap 'rm -f "$TEMP_FILE"' EXIT
# First, call the python script to get list of packages and versions
echo "Gathering package versions..."
python3 -m get_packages_to_tag > "$TEMP_FILE"
# Store commands in an array
declare -a COMMANDS=()
# Read the temporary file line by line
while IFS=': ' read -r name version; do
# Skip empty lines or lines with errors
if [ -z "$name" ] || [ -z "$version" ]; then
continue
fi
# Remove any whitespace
name=$(echo "$name" | tr -d '[:space:]')
version=$(echo "$version" | tr -d '[:space:]')
# Create the tag name
tag="${name}@v${version}"
# Add commands to array
COMMANDS+=("git tag -a \"$tag\" -m \"Release $name version $version\"")
COMMANDS+=("git push origin \"$tag\"")
done < "$TEMP_FILE"
# Print all commands that will be executed
if [ ${#COMMANDS[@]} -eq 0 ]; then
echo "No packages found to tag!"
exit 1
fi
echo -e "\nThe following commands will be executed:"
printf '%s\n' "${COMMANDS[@]}"
# If in prod mode, ask for confirmation
if [ "$PROD_MODE" = true ]; then
echo -e "\nEnter Y to confirm: "
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
echo "Executing commands..."
for cmd in "${COMMANDS[@]}"; do
echo "Running: $cmd"
eval "$cmd"
if [ $? -ne 0 ]; then
echo "Error executing command: $cmd" >&2
exit 1
fi
done
echo "All tags created and pushed successfully!"
else
echo "Operation cancelled by user."
exit 0
fi
else
echo -e "\nDry run complete. Run with --prod flag to execute these commands."
fi