-
Notifications
You must be signed in to change notification settings - Fork 2
/
bump-version.sh
executable file
·39 lines (31 loc) · 1.11 KB
/
bump-version.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
function replace_line_in_file () {
file="$1"
line_num="$2"
replacement="$3"
replacement_escaped=$( echo "$replacement" | sed -e 's/[\/&]/\\&/g' )
sed -i '' "${line_num}s/.*/$replacement_escaped/" "$file"
}
filePath="Formula/vtex.rb"
echo "Downloading latest release..."
allData=$(curl -sk https://vtex-toolbelt-test.s3.us-east-2.amazonaws.com/darwin-x64)
version=$(echo $allData | jq --raw-output '.version')
url=$(echo $allData | jq --raw-output '.gz')
sha256=$(echo $allData | jq --raw-output '.sha256gz')
echo "Latest verison: $version"
url=" url \"$url\""
version=" version \"$version\""
sha256=" sha256 \"$sha256\""
echo "Bumping brew version..."
replace_line_in_file "$filePath" 4 "$url"
replace_line_in_file "$filePath" 5 "$version"
replace_line_in_file "$filePath" 6 "$sha256"
fileUrlData=$(sed -n 4p "$filePath")
fileVersionData=$(sed -n 5p "$filePath")
fileSha256Data=$(sed -n 6p "$filePath")
if [ "$fileUrlData" = "$url" ] && [ "$fileVersionData" = "$version" ] && [ "$fileSha256Data" = "$sha256" ]
then
echo "Version bumped successfully!"
else
echo "Failed to bump version."
exit 1
fi