forked from Ozon3Org/Ozon3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateVersion.sh
61 lines (45 loc) · 1.73 KB
/
updateVersion.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
#!/usr/bin/bash
# This script is used for automating the process of updating patch numbers.
# Specifically, it updates the version number in setup.cfg (Line 3) and setup.py (Line 12 & 13)
# You can provide the script with either major, minor or patch (Case sensitive)
# Example usage:
# If the current version is 1.4.0, running './updateVersion.sh major' will change
# the current version to 2.0.0
if [ "$1" = "" ]; then
echo "You must provide an argument for this script"
echo "Your argument must be either major, minor or patch"
echo "See version semantics for more"
exit
fi
if [ "$1" != "major" ] && [ "$1" != "minor" ] && [ "$1" != "patch" ]; then
echo "Incorrect argument provided"
echo "Your argument must be either major, minor or patch (Case sensitive)"
exit
fi
VERSION_STRING=$(cat setup.cfg | grep "version")
IFS=' '
read -ra VERSION_STRING_ARR <<< $VERSION_STRING
VERSION="${VERSION_STRING_ARR[@]:2:2}"
echo "Current Version: $VERSION"
IFS='.'
read -ra VERSION_NUMBERS <<< $VERSION
MAJOR=${VERSION_NUMBERS[@]::1}
MINOR=${VERSION_NUMBERS[@]:1:1}
PATCH=${VERSION_NUMBERS[@]:2:2}
if [ "$1" = "major" ]; then
PATCH="0"
MINOR="0"
MAJOR=$(( $MAJOR + 1))
fi
if [ "$1" = "minor" ]; then
PATCH="0"
MINOR=$(( $MINOR + 1))
fi
if [ "$1" = "patch" ]; then
PATCH=$(( $PATCH + 1))
fi
UPDATED_VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "Updated Version: $UPDATED_VERSION"
sed -i "s/version = ${VERSION}/version = ${UPDATED_VERSION}/" setup.cfg
sed -i "s/^ version=\"${VERSION}\",/ version=\"${UPDATED_VERSION}\",/" setup.py
sed -i "s/^ download_url=\"https:\/\/github.com\/Ozon3Org\/Ozon3\/archive\/refs\/tags\/v${VERSION}.tar.gz\",/ download_url=\"https:\/\/github.com\/Ozon3Org\/Ozon3\/archive\/refs\/tags\/v${UPDATED_VERSION}.tar.gz\",/" setup.py