-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathretag.sh
executable file
·45 lines (37 loc) · 1.24 KB
/
retag.sh
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
#!/bin/bash
# This script replaces the old tag with the new tag in the files listed in the files array.
# Usage: ./retag.sh <new_tag>
# Example: ./retag.sh 0.1.0
# -h or --help: Show help message
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo "This script replaces the old tag with the new tag in the files listed in the files array."
echo "Usage: ./retag.sh <new_tag>"
echo "Example: ./retag.sh 0.1.0"
exit 0
fi
# Verifica se o arquivo VERSION.txt existe
if [ ! -f "VERSION.txt" ]; then
echo "Arquivo VERSION.txt não encontrado."
exit 1
fi
# Lê a última tag do arquivo VERSION.txt
last_tag=$(<VERSION.txt)
# Verifica se a nova tag foi fornecida como argumento
if [ "$#" -ne 1 ]; then
echo "Uso: $0 <new_tag>"
exit 1
fi
new_tag=$1
files=("valu3/Cargo.toml" "valu3_derive/Cargo.toml" "valu3/README.md" "valu3_derive/README.md" "README.md" "VERSION.txt")
# Loop através dos files e realiza o replace
for file in "${files[@]}"; do
if [ -f "$file" ]; then
if sed -i "s|$last_tag|$new_tag|g" "$file"; then
echo "Substituído '$last_tag' por '$new_tag' em $file"
else
echo "Erro ao substituir em $file"
fi
else
echo "Arquivo $file não encontrado."
fi
done