Jose Diaz-Gonzalez
commited on
Commit
·
d49484e
1
Parent(s):
7e36cb4
Add release script
Browse files
release
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
# Colors
|
4 |
+
COLOR_OFF="\033[0m" # unsets color to term fg color
|
5 |
+
RED="\033[0;31m" # red
|
6 |
+
GREEN="\033[0;32m" # green
|
7 |
+
YELLOW="\033[0;33m" # yellow
|
8 |
+
MAGENTA="\033[0;35m" # magenta
|
9 |
+
CYAN="\033[0;36m" # cyan
|
10 |
+
|
11 |
+
if [[ "$@" != "major" ]] && [[ "$@" != "minor" ]] && [[ "$@" != "patch" ]]; then
|
12 |
+
echo -e "${RED}WARNING: Invalid release type, must specify 'major', 'minor', or 'patch'${COLOR_OFF}\n"
|
13 |
+
exit
|
14 |
+
fi
|
15 |
+
|
16 |
+
echo -e "\n${GREEN}STARTING RELEASE PROCESS${COLOR_OFF}\n"
|
17 |
+
|
18 |
+
git status | grep "working directory clean" &> /dev/null
|
19 |
+
if [ ! $? -eq 0 ]; then # working directory is NOT clean
|
20 |
+
echo -e "${RED}WARNING: You have uncomitted changes, you may have forgotten something${COLOR_OFF}\n"
|
21 |
+
exit
|
22 |
+
fi
|
23 |
+
|
24 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Updating local copy"
|
25 |
+
git pull -q origin master
|
26 |
+
|
27 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Retrieving release versions"
|
28 |
+
|
29 |
+
current_version=`cat pytube/__init__.py |grep '__version__ ='|sed 's/[^0-9.]//g'`
|
30 |
+
major=`echo $current_version | awk '{split($0,a,"."); print a[1]}'`
|
31 |
+
minor=`echo $current_version | awk '{split($0,a,"."); print a[2]}'`
|
32 |
+
patch=`echo $current_version | awk '{split($0,a,"."); print a[3]}'`
|
33 |
+
|
34 |
+
if [[ "$@" == "major" ]]; then
|
35 |
+
major=$(($major + 1));
|
36 |
+
minor="0"
|
37 |
+
patch="0"
|
38 |
+
elif [[ "$@" == "minor" ]]; then
|
39 |
+
minor=$(($minor + 1));
|
40 |
+
patch="0"
|
41 |
+
elif [[ "$@" == "patch" ]]; then
|
42 |
+
patch=$(($patch + 1));
|
43 |
+
fi
|
44 |
+
|
45 |
+
next_version="${major}.${minor}.${patch}"
|
46 |
+
|
47 |
+
echo -e "${YELLOW} >${COLOR_OFF} ${MAGENTA}${current_version}${COLOR_OFF} -> ${MAGENTA}${next_version}${COLOR_OFF}"
|
48 |
+
|
49 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Creating necessary temp file"
|
50 |
+
tempfoo=`basename $0`
|
51 |
+
TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || {
|
52 |
+
echo -e "${RED}WARNING: Cannot create temp file using mktemp in /tmp dir ${COLOR_OFF}\n"
|
53 |
+
exit 1
|
54 |
+
}
|
55 |
+
|
56 |
+
find_this="__version__ = '$current_version'"
|
57 |
+
replace_with="__version__ = '$next_version'"
|
58 |
+
|
59 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Updating pytube/__init__.py"
|
60 |
+
sed "s/$find_this/$replace_with/" pytube/__init__.py > $TMPFILE && mv $TMPFILE pytube/__init__.py
|
61 |
+
|
62 |
+
find_this="pytube.git@$current_version"
|
63 |
+
replace_with="pytube.git@$next_version"
|
64 |
+
|
65 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Updating README.rst"
|
66 |
+
sed "s/$find_this/$replace_with/" README.rst > $TMPFILE && mv $TMPFILE README.rst
|
67 |
+
|
68 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Updating CHANGES.rst for new release"
|
69 |
+
version_header="$next_version ($(date +%F))"
|
70 |
+
dashes=`yes '-'|head -n ${#version_header}|tr -d '\n'`
|
71 |
+
gitchangelog |sed "4s/.*/$version_header/"|sed "5s/.*/$dashes/" > $TMPFILE && mv $TMPFILE CHANGES.rst
|
72 |
+
|
73 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Adding changed files to git"
|
74 |
+
git add CHANGES.rst README.rst pytube/__init__.py
|
75 |
+
|
76 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Creating release"
|
77 |
+
git commit -q -m "Release version $next_version"
|
78 |
+
|
79 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Tagging release"
|
80 |
+
git tag -a $next_version -m "Release version $next_version"
|
81 |
+
|
82 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Pushing release and tags to github"
|
83 |
+
git push -q origin master && git push -q --tags
|
84 |
+
|
85 |
+
echo -e "${YELLOW}--->${COLOR_OFF} Creating python release"
|
86 |
+
cp README.rst README
|
87 |
+
python setup.py sdist upload > /dev/null
|
88 |
+
rm README
|
89 |
+
|
90 |
+
echo -e "\n${CYAN}RELEASED VERSION ${next_version}!${COLOR_OFF}\n"
|