Skip to content

Commit a681e6d

Browse files
Merge pull request #798 from Labelbox/kkim/helper_script_sdk_version
[AL-4434] Add helper script to update SDK version
2 parents 0ccd47b + 76e0b58 commit a681e6d

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

scripts/update_sdk_version.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env bash
2+
3+
usage="$(basename "$0") [-h] [-v] -- Script to update necessary files for SDK version release
4+
5+
where:
6+
-h Show help text
7+
-v New SDK version"
8+
9+
while getopts ':hv:' option; do
10+
case "$option" in
11+
h) echo "$usage"
12+
exit
13+
;;
14+
v) new_version=$OPTARG
15+
;;
16+
:) printf "missing argument for -%s\n" "$OPTARG" >&2
17+
echo "$usage" >&2
18+
exit 1
19+
;;
20+
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
21+
echo "$usage" >&2
22+
exit 1
23+
;;
24+
esac
25+
done
26+
27+
if [ $# -eq 0 ]
28+
then
29+
echo "No SDK version is specified"
30+
echo "$usage" >&2
31+
exit;
32+
fi
33+
34+
SDK_PATH="$( cd -- "$(dirname "$0")" | cd .. >/dev/null 2>&1 ; pwd -P )"
35+
INIT_FILE="$SDK_PATH/labelbox/__init__.py"
36+
READTHEDOCS_CONF_FILE="$SDK_PATH/docs/source/conf.py"
37+
CHANGELOGS_FILE="$SDK_PATH/CHANGELOG.md"
38+
39+
old_version=$(cat $SDK_PATH/labelbox/__init__.py | grep __version__ | cut -d '=' -f2 | tr -d ' ' | tr -d '"')
40+
41+
echo "New version: $new_version"
42+
echo "Old version: $old_version"
43+
44+
escaped_old_version=$(echo "$old_version" | sed "s/\./\\\./g")
45+
escaped_new_version=$(echo "$new_version" | sed "s/\./\\\./g")
46+
47+
sed -i "" "s/$escaped_old_version/$escaped_new_version/" $INIT_FILE
48+
echo "Updated '$INIT_FILE'"
49+
50+
sed -i "" "s/$escaped_old_version/$escaped_new_version/" $READTHEDOCS_CONF_FILE
51+
echo "Updated '$READTHEDOCS_CONF_FILE'"
52+
echo "Successfully updated SDK version locally!"
53+
54+
echo "\nOpening CHANGELOGS file in text editor"
55+
open -e $CHANGELOGS_FILE
56+
57+
echo "\nPlease open a PR to finish the release process using the following git commands:"
58+
echo "\ngit add --all"
59+
echo "git commit -m 'Preparing for $new_version release'"
60+
echo "git push origin prep_$new_version"

0 commit comments

Comments
 (0)