-
Notifications
You must be signed in to change notification settings - Fork 0
/
bump-version.sh
67 lines (48 loc) · 1.47 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
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
#!/bin/bash
set -e
# Change current version number in all project files.
# Running this script implies there are no "CURRENT_VERSION" strings in the project.
# Otherwise the strings will be replaced.
# NB! Other package versions should be specified like "^PACKAGE_VERSION".
# Formatting:
BOLD="\033[1m"
BLUE="\033[34m"
RED="\033[31m"
RESET="\033[0m"
# Global arguments:
# Curremt project version
CURRENT_VERSION="0.0.2"
# New project version (same as current by default)
NEW_VERSION="$CURRENT_VERSION"
# Files that require versioning
VERSIONED_FILES=(
"Makefile" \
"README.md" \
"bump-version.sh" \
".github/scripts/package.json" \
"viridian/algae/pyproject.toml" \
"viridian/algae/README.md" \
"viridian/algae/sources/coordinator.py" \
"caerulean/whirlpool/README.md" \
"caerulean/whirlpool/whirlpool.sh" \
"caerulean/whirlpool/sources/server.go"
)
# Functions:
function help() {
echo -e "${BOLD}Version bumping script usage:${RESET}"
echo -e "\t${BLUE}-v [NEW_VERSION]${RESET}: New version for the project files."
echo -e "\t${BLUE}-h${RESET}: Print this message again and exit."
}
# CLI flags and options:
while getopts "v:h" flag
do
case "${flag}" in
v) NEW_VERSION=${OPTARG};;
h) help && exit 1;;
*) echo -e "${RED}Invalid flag found: $flag${RESET}" && exit 1;;
esac
done
# Script body:
for file in "${VERSIONED_FILES[@]}" ; do
sed -i -e "s/\"$CURRENT_VERSION\"/\"$NEW_VERSION\"/g" "$file"
done