File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "release" :{
3+ "tags" :{
4+ "mainnet" :" minaprotocol/mina-daemon:3.0.3-d800da8-bullseye-mainnet" ,
5+ "devnet" :" gcr.io/o1labs-192920/mina-daemon:3.0.1-alpha1-0473756-bullseye-devnet"
6+ }
7+ }
8+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ SCRIPT_DIR=" $( dirname " $( realpath " ${BASH_SOURCE[0]} " ) " ) "
4+
5+ cd $SCRIPT_DIR /..
6+
7+ if [[ " $1 " == " -h" || " $1 " == " --help" || $# -ne 2 ]]; then
8+ cat << EOF
9+ Usage: ${0##*/ } [-h|--help] <new_mainnet_tag> <new_devnet_tag>
10+
11+ This script take new_mainnet_tag and new_devnet_tag, scan through the whole repo
12+ and replace old tags them with provided new tags.
13+
14+ -h|--help display this help and exit
15+ EOF
16+ exit 0
17+ fi
18+
19+ NEW_MAINNET_TAG=" $1 "
20+ NEW_DEVNET_TAG=" $2 "
21+
22+ # Unified function: handles reading, logging, and replacing
23+ process_tag () {
24+ local json_key=" $1 "
25+ local new_value=" $2 "
26+
27+ local old_value
28+ old_value=$( jq -r " $json_key " ./metadata.json)
29+
30+ if [ -z " $old_value " ]; then
31+ echo " Failed to read $json_key from metadata.json"
32+ exit 1
33+ fi
34+
35+ echo " $json_key : $old_value → $new_value "
36+
37+ escaped_old_value=$( printf ' %s\n' " $old_value " | sed ' s/[\/&]/\\&/g' )
38+ escaped_new_value=$( printf ' %s\n' " $new_value " | sed ' s/[\/&]/\\&/g' )
39+
40+ grep -rl --exclude-dir=.git " $old_value " . | while read -r file; do
41+ sed -i " s/$escaped_old_value /$escaped_new_value /g" " $file "
42+ done
43+ }
44+
45+ echo " Replacing release tags:"
46+ process_tag ' .release.tags.mainnet' " $NEW_MAINNET_TAG "
47+ process_tag ' .release.tags.devnet' " $NEW_DEVNET_TAG "
48+
49+ echo " Replacement complete."
You can’t perform that action at this time.
0 commit comments