Skip to content

Commit 89132f5

Browse files
committed
Update release script
1 parent 433ea29 commit 89132f5

1 file changed

Lines changed: 34 additions & 11 deletions

File tree

release

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
2+
set -eo pipefail; [[ $RELEASE_TRACE ]] && set -x
23

34
PACKAGE_NAME='beaver'
5+
INIT_PACKAGE_NAME='beaver'
46
PUBLIC="true"
57

68
# Colors
@@ -11,28 +13,46 @@ YELLOW="\033[0;33m" # yellow
1113
MAGENTA="\033[0;35m" # magenta
1214
CYAN="\033[0;36m" # cyan
1315

16+
# ensure wheel is available
17+
pip install wheel > /dev/null
18+
19+
# ensure Pygment is available
20+
pip install Pygments > /dev/null
21+
22+
command -v gitchangelog >/dev/null 2>&1 || {
23+
echo -e "${RED}WARNING: Missing gitchangelog binary, please run: pip install gitchangelog==2.2.0${COLOR_OFF}\n"
24+
exit 1
25+
}
26+
27+
command -v rst-lint > /dev/null || {
28+
echo -e "${RED}WARNING: Missing rst-lint binary, please run: pip install restructuredtext_lint${COLOR_OFF}\n"
29+
exit 1
30+
}
31+
1432
if [[ "$@" != "major" ]] && [[ "$@" != "minor" ]] && [[ "$@" != "patch" ]]; then
1533
echo -e "${RED}WARNING: Invalid release type, must specify 'major', 'minor', or 'patch'${COLOR_OFF}\n"
1634
exit 1
1735
fi
1836

1937
echo -e "\n${GREEN}STARTING RELEASE PROCESS${COLOR_OFF}\n"
2038

39+
set +e;
2140
git status | grep "working directory clean" &> /dev/null
2241
if [ ! $? -eq 0 ]; then # working directory is NOT clean
2342
echo -e "${RED}WARNING: You have uncomitted changes, you may have forgotten something${COLOR_OFF}\n"
2443
exit 1
2544
fi
45+
set -e;
2646

2747
echo -e "${YELLOW}--->${COLOR_OFF} Updating local copy"
2848
git pull -q origin master
2949

3050
echo -e "${YELLOW}--->${COLOR_OFF} Retrieving release versions"
3151

32-
current_version=`cat ${PACKAGE_NAME}/__init__.py |grep '__version__ ='|sed 's/[^0-9.]//g'`
33-
major=`echo $current_version | awk '{split($0,a,"."); print a[1]}'`
34-
minor=`echo $current_version | awk '{split($0,a,"."); print a[2]}'`
35-
patch=`echo $current_version | awk '{split($0,a,"."); print a[3]}'`
52+
current_version=$(cat ${INIT_PACKAGE_NAME}/__init__.py |grep '__version__ ='|sed 's/[^0-9.]//g')
53+
major=$(echo $current_version | awk '{split($0,a,"."); print a[1]}')
54+
minor=$(echo $current_version | awk '{split($0,a,"."); print a[2]}')
55+
patch=$(echo $current_version | awk '{split($0,a,"."); print a[3]}')
3656

3757
if [[ "$@" == "major" ]]; then
3858
major=$(($major + 1));
@@ -49,18 +69,21 @@ next_version="${major}.${minor}.${patch}"
4969

5070
echo -e "${YELLOW} >${COLOR_OFF} ${MAGENTA}${current_version}${COLOR_OFF} -> ${MAGENTA}${next_version}${COLOR_OFF}"
5171

72+
echo -e "${YELLOW}--->${COLOR_OFF} Ensuring readme passes lint checks (if this fails, run rst-lint)"
73+
rst-lint README.rst > /dev/null
74+
5275
echo -e "${YELLOW}--->${COLOR_OFF} Creating necessary temp file"
53-
tempfoo=`basename $0`
54-
TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || {
76+
tempfoo=$(basename $0)
77+
TMPFILE=$(mktemp /tmp/${tempfoo}.XXXXXX) || {
5578
echo -e "${RED}WARNING: Cannot create temp file using mktemp in /tmp dir ${COLOR_OFF}\n"
5679
exit 1
5780
}
5881

5982
find_this="__version__ = '$current_version'"
6083
replace_with="__version__ = '$next_version'"
6184

62-
echo -e "${YELLOW}--->${COLOR_OFF} Updating ${PACKAGE_NAME}/__init__.py"
63-
sed "s/$find_this/$replace_with/" ${PACKAGE_NAME}/__init__.py > $TMPFILE && mv $TMPFILE ${PACKAGE_NAME}/__init__.py
85+
echo -e "${YELLOW}--->${COLOR_OFF} Updating ${INIT_PACKAGE_NAME}/__init__.py"
86+
sed "s/$find_this/$replace_with/" ${INIT_PACKAGE_NAME}/__init__.py > $TMPFILE && mv $TMPFILE ${INIT_PACKAGE_NAME}/__init__.py
6487

6588
echo -e "${YELLOW}--->${COLOR_OFF} Updating README.rst"
6689
find_this="${PACKAGE_NAME}.git@$current_version"
@@ -83,15 +106,15 @@ fi
83106

84107
echo -e "${YELLOW}--->${COLOR_OFF} Updating CHANGES.rst for new release"
85108
version_header="$next_version ($(date +%F))"
86-
dashes=`yes '-'|head -n ${#version_header}|tr -d '\n'`
109+
set +e; dashes=$(yes '-'|head -n ${#version_header}|tr -d '\n') ; set -e
87110
gitchangelog |sed "4s/.*/$version_header/"|sed "5s/.*/$dashes/" > $TMPFILE && mv $TMPFILE CHANGES.rst
88111

89112
echo -e "${YELLOW}--->${COLOR_OFF} Updating debian/changelog"
90113
dch -v $next_version "Release version $next_version"
91114
dch -r stable
92115

93116
echo -e "${YELLOW}--->${COLOR_OFF} Adding changed files to git"
94-
git add CHANGES.rst README.rst debian/changelog ${PACKAGE_NAME}/__init__.py
117+
git add CHANGES.rst README.rst debian/changelog ${INIT_PACKAGE_NAME}/__init__.py
95118
if [ -f docs/conf.py ]; then git add docs/conf.py; fi
96119

97120
echo -e "${YELLOW}--->${COLOR_OFF} Creating release"
@@ -106,7 +129,7 @@ git push -q origin master && git push -q --tags
106129
if [[ "$PUBLIC" == "true" ]]; then
107130
echo -e "${YELLOW}--->${COLOR_OFF} Creating python release"
108131
cp README.rst README
109-
python setup.py sdist upload > /dev/null
132+
python setup.py sdist bdist_wheel upload > /dev/null
110133
rm README
111134
fi
112135

0 commit comments

Comments
 (0)