-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·48 lines (39 loc) · 1.2 KB
/
publish.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
#!/bin/bash
set -e
VERSION=$1
PROJECT=jsview
cd $(dirname $0)
# Check if version has been provided
if [[ "$VERSION" == "" ]]; then
CURRENT_VERSION=$(cat $PROJECT/__init__.py | grep '^\s*__version__\s*=' | cut -d'"' -f2)
echo "Usage: $0 <new_version number>. Current version is ${CURRENT_VERSION}."
if git tag | grep -q "^v$CURRENT_VERSION$"; then
echo "This version has already been tagged."
else
echo "This version has not been tagged yet."
fi
exit 1
fi
if [[ ! -f .credentials ]]; then
echo "Missing a .credentials file with LOGIN=xxx and PASSWORD=xxx lines"
exit 2
fi
# Change version in sources
sed -i "s/^__version__\\s*=.*/__version__ = \"$VERSION\"/" $PROJECT/__init__.py
# Commit + tag + push change(s)
if [[ $(git status -s) != "" ]]; then
echo "Uncommitted files, please commit and try again"
exit 3
# git commit -am "Published version $VERSION"
fi
git tag -a "v$VERSION" -m "Published version $VERSION"
git push
# Rebuild
python3 setup.py sdist bdist_wheel || exit 1
# Publish
. .credentials
twine upload \
--username "$LOGIN" \
--password "$PASSWORD" \
--repository-url https://upload.pypi.org/legacy/ \
dist/*-$VERSION.*