-
Notifications
You must be signed in to change notification settings - Fork 9
/
release.sh
executable file
·141 lines (128 loc) · 4.68 KB
/
release.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
#########################################################################
# Copyright (C) 2018 IAIK TU Graz ([email protected])
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#########################################################################
# @file release.sh
# @brief Sets up a Python virtual environment.
# @author Samuel Weiser <[email protected]>
# @license This project is released under the GNU GPLv3 License.
#########################################################################
VER=$(python -c 'from datagui import DATAGUI_VERSION; print(DATAGUI_VERSION)')
VER_ORIG=$VER
#------------------------------------------------------------------------
# Check whether parent repository is on 'master'
#------------------------------------------------------------------------
GUICI=$(git rev-parse HEAD)
GUIBRANCH=$(git rev-parse --abbrev-ref HEAD)
pushd ..
DATACI=$(git rev-parse HEAD)
DATABRANCH=$(git rev-parse --abbrev-ref HEAD)
DEVELOP=0
if ! [[ "${DATABRANCH}" == "master" ]] || ! [[ "${GUIBRANCH}" == "master" ]]; then
if ! [[ "$1" == "-f" ]]; then
echo "GUI and DATA repo must be on master branch!"
echo "This ensures that a DATA GUI package only include released"
echo "DATA files."
echo ""
echo "To still continue for a development package, append -f"
exit 1
else
DEVELOP=1
VER="${VER}-DATA-${DATABRANCH}-${DATACI:0:7}-GUI-${GUIBRANCH}-${GUICI:0:7}"
echo "Creating develop version: $VER"
fi
fi
popd
#------------------------------------------------------------------------
# Check version number
#------------------------------------------------------------------------
export TAR=dist/datagui-${VER}.tar.gz
if [[ -f "${TAR}" ]]; then
echo "Release ${VER} already exists in ${TAR}"
echo "Increment version number in datagui/__init__.py"
exit 1
fi
#------------------------------------------------------------------------
# Update version number in all license headers
#------------------------------------------------------------------------
UNTRACKED=$(git status --porcelain | grep -e "^??")
if ! [[ -z "${UNTRACKED}" ]]; then
echo "You have untracked files. Track them or add them to .gitignore!"
echo "${UNTRACKED}"
exit 1
fi
UNCOMMITTED=$(git diff-index HEAD)
if ! [[ -z "${UNCOMMITTED}" ]]; then
echo "You have uncommitted files. Commit or stash them!"
echo "${UNCOMMITTED}"
exit 1
fi
echo "Setting version number"
for f in `git ls-files`; do
if [[ "$f" == "release.sh" ]]; then
continue
fi
grep "@version" $f > /dev/null
if [[ "$?" -eq "0" ]]; then
echo "Setting version number in $f"
# search for '@version' string and
# replace the following version number with ${VER}
sed -i "s/\(@version\s*\).*/\1${VER}/g" $f
fi
done
for f in `git ls-files`; do
if [[ "$f" == "release.sh" ]]; then
continue
fi
grep "DATAGUI_VERSION" $f > /dev/null
if [[ "$?" -eq "0" ]]; then
echo "Setting version number in $f"
# search for 'DATAGUI_VERSION' string and
# replace the following version number with ${VER}
sed -i "s/\(DATAGUI_VERSION\s*=\s*\).*/\1'${VER}'/g" $f
fi
done
#------------------------------------------------------------------------
# Create fresh environment
#------------------------------------------------------------------------
set -e
ENV=.pyenv
rm -rf ${ENV}
LOAD_PYENV_INTERPRETER=/usr/bin/python3
virtualenv -p ${LOAD_PYENV_INTERPRETER} ${ENV}
source ${ENV}/bin/activate
pip install --upgrade pip
pip install --upgrade setuptools
set +e
#------------------------------------------------------------------------
# Package DATA GUI
#------------------------------------------------------------------------
python setup.py sdist || retval=$?
if [[ "$retval" -ne "0" ]] || ! [[ -f "${TAR}" ]]; then
echo "Failed to create python package"
exit 1
fi
if [[ "${DEVELOP}" -eq "1" ]]; then
echo "Reverting temporary @version changes"
git checkout .
else
echo "Please commit the @version changes"
fi
#------------------------------------------------------------------------
# Try to install and run package
#------------------------------------------------------------------------
pip install "${TAR}"
datagui