-
Notifications
You must be signed in to change notification settings - Fork 1
/
version.sh
executable file
·40 lines (33 loc) · 929 Bytes
/
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
40
#!/bin/bash
VALID_SEMVER='[0-9]*\.[0-9]*\.[0-9]*'
# get current version
current_version=$(grep -m 1 -o ${VALID_SEMVER} docker-compose.yml)
echo "Current version: ${current_version}"
# get new version from user input
read -p 'Enter the new version (e.g. 1.0.1): ' version
# confirm that version is in the correct format
exp='^'${VALID_SEMVER}'$'
if [[ ! $version =~ $exp ]]; then
echo "Error: ${version} is not formatted correctly."
exit 1
fi
echo "Updating files..."
# update docker-compose.yml
echo -n "docker-compose.yml ... "
exp='s/'${VALID_SEMVER}'/'${version}'/g'
perl -i -pe $exp docker-compose.yml
echo "done"
# update client package files
echo -n "client/package*.json ... "
cd client
npm version $version &>/dev/null
cd ..
echo "done"
# update server package files
echo -n "server/package*.json ... "
cd server
npm version $version &>/dev/null
cd ..
echo "done"
# done
echo "All files updated to ${version}"