-
Notifications
You must be signed in to change notification settings - Fork 110
/
release.sh
executable file
·32 lines (32 loc) · 1.07 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
#!/bin/bash
# pip release scripts that auto-updates version number and keeps trying until successful
set -x
set -u
i=0
#https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3
pip install twine
while true
do
rm -rf build
i=$((i+1))
output=$(grep version= setup.py | awk -F'=' '{print $2}' | sed "s/'\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\)',/\1 \2 \3/")
major=$(echo "${output}" | awk '{print $1}')
minor=$(echo "${output}" | awk '{print $2}')
point=$(echo "${output}" | awk '{print $3}')
newpoint=$((point+1))
sed -i "s/\([ \s]\)*version=\(.\)$major.$minor.$point\(.\).*/\1version=\2$major.$minor.$newpoint\3,/" setup.py
sed -i "s/^shutit_version=\(.\)${major}.${minor}.[0-9][0-9]*\(.\).*/shutit_version=\1${major}.${minor}.${newpoint}\2/" shutit.py
#if python setup.py sdist bdist_wheel upload
if python setup.py sdist
then
twine upload dist/*
break
fi
# wait a minute
sleep 60
done
git commit -am "release: ${major}.${minor}.${newpoint}"
echo Success after ${i} attempts
git push
git tag -f "${major}.${minor}.${newpoint}"
git push --tags