-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·102 lines (84 loc) · 2.71 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
#!/bin/bash
usage() {
echo "Usage: $0 [options]" 1>&2;
echo " -g: Skip the history entry and git commits/tags." 1>&2;
echo " -r [patch|minor|major]: The type of update (default patch)." 1>&2;
echo " -p (python versions): A comma separated list of versions to test against (default ALL)." 1>&2
exit 1;
}
skipGit=false
release="patch"
pythonVersions="ALL"
while getopts "gp:r:" o; do
case "${o}" in
g)
skipGit=true
;;
p)
pythonVersions=${OPTARG}
;;
r)
release=${OPTARG}
if [[ "$release" != "major" && "$release" != "minor" && "$release" != "patch" ]]
then
echo "The release type must be patch, minor or major.";
usage
fi
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
echo $skipGit
lastVersion=`git tag | tail -1`
if $skipGit
then
newVersion=$lastVersion
else
# Compute the new version number.
major=`echo $lastVersion | sed 's|v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)|\1|g'`
minor=`echo $lastVersion | sed 's|v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)|\2|g'`
patch=`echo $lastVersion | sed 's|v\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)|\3|g'`
if [[ "$release" == "major" ]]
then
major=$(($major + 1))
minor=0
patch=0
fi
if [[ "$release" == "minor" ]]
then
minor=$(($minor + 1))
patch=0
fi
if [[ "$release" == "patch" ]]
then
patch=$(($patch + 1))
fi
newVersion="$major.$minor.$patch"
# Update HISTORY.rst
scite HISTORY.rst
# Commit the changes:
git add HISTORY.rst
git commit -m "Changelog for upcoming release $newVersion."
# Update version number
bumpversion "$release" || exit 1
fi
# Install the package again for local development, but with the new version number:
sudo python setup.py develop
# Run the tests:
tox -e "$pythonVersions" || exit 1
# Release on PyPI by uploading both sdist and wheel:
python3 setup.py sdist upload
python3 setup.py bdist_wheel upload
# Push:
git push origin HEAD:master
# Push tags:
git push --tags
# Check the PyPI listing page to make sure that the README, release notes, and roadmap display properly. If not, copy and paste the RestructuredText into http://rst.ninjs.org/ to find out what broke the formatting.
# Edit the release on GitHub (e.g. https://github.com/audreyr/cookiecutter/releases). Paste the release notes into the release's release page, and come up with a title for the release.
# Create the snap and upload it.
snapcraft cleanbuild
versionWithoutV=`echo $newVersion | sed "s|v||g"`
snapcraft push "mountain-tapir_"$versionWithoutV"_amd64.snap" --release beta