-
Notifications
You must be signed in to change notification settings - Fork 74
/
make-release
executable file
·119 lines (87 loc) · 3.42 KB
/
make-release
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
#!/bin/bash
# How to use this script:
# 1) Make sure that the git index is what you want to release
# 2) Edit setup.py in the working copy to set the new version number
# 3) Run this script
# 4) If the generated package is ok, copy and paste the commands output
# by this script in order to commit the new setup.py and changelog
# and build the source distribution archive
set -e
# Defaults
packagename=python-dali
distribution=unstable
urgency=low
tmpdir=release-tmp
usage="make-release [ -p packagename ] [ -d distribution ]
[ -u urgency ] [ -t tmpdir ] [ -r ]"
rerelease=no
while getopts "p:d:u:t:hrs" options; do
case $options in
p ) packagename=$OPTARG;;
d ) distribution=$OPTARG;;
u ) urgency=$OPTARG;;
t ) tmpdir=$OPTARG;;
h ) echo "$usage" ; exit;;
r ) echo "Re-release: skipping version number and changelog update"
rerelease=yes;;
\? ) echo "$usage"
exit 1;;
* ) echo "$usage"
exit 1;;
esac
done
# Find the new version number.
newversion=$(./setup.py -V)
echo "New version: ${newversion}"
# Find the previous version number
rm -rf ${tmpdir}
mkdir ${tmpdir}
pkgdir=${tmpdir}/${packagename}-${newversion}
git checkout-index -a --prefix=${pkgdir}/
releasedate="$(date -R)"
version="${newversion} (${releasedate})"
# Put the version number in the version.py file
echo "version=\"${version}\"" >${pkgdir}/dali/version.py
if [ "${rerelease}" = "yes" ]; then
(cd ${pkgdir} ; dpkg-buildpackage -rfakeroot -us -uc)
echo "Rebuilt package is in ${tmpdir}"
exit 0
fi
oldversion=$(dpkg-parsechangelog -l${pkgdir}/debian/changelog | grep Version: | sed 's/Version: //')
echo "Previous version: ${oldversion}"
if [ "${oldversion}" = "${newversion}" ]; then
echo Versions are the same! Have you forgotten to update setup.cfg?
echo If you are rebuilding the current release, use the -r option
exit 1
fi
# Construct a changelog entry with the new version number
mv ${pkgdir}/debian/changelog ${pkgdir}/debian/changelog.old
echo -e "${packagename} (${newversion}) ${distribution}; urgency=${urgency}\n" >${pkgdir}/debian/changelog
echo -e " * New release ${newversion}\n" >>${pkgdir}/debian/changelog
git log '--pretty=format: * %s%n' v${oldversion}.. -- >>${pkgdir}/debian/changelog
echo -e "\n -- $(git config --get user.name) <$(git config --get user.email)> ${releasedate}\n">>${pkgdir}/debian/changelog
cat ${pkgdir}/debian/changelog.old >>${pkgdir}/debian/changelog
rm ${pkgdir}/debian/changelog.old
# Copy the working tree setup.cfg into the temporary tree - it has
# the version number that we want to use for the generated package.
cp setup.cfg ${pkgdir}/setup.cfg
# Build the Debian package files
(cd ${pkgdir} ; dpkg-buildpackage -rfakeroot -us -uc)
# If we reach this point, we should have Debian packages built in ${tmpdir}
# Copy the changelog back to the working tree and add it to the index
cp ${pkgdir}/debian/changelog debian/changelog
echo "debian/changelog updated, but not yet added to the index."
dpkg-parsechangelog
cat <<EOF
You can commit this release by pasting the following commands:
git add setup.cfg debian/changelog
git commit -m "${packagename} ${newversion}"
git tag -a -m "Version ${newversion}" v${newversion}
The following files should be put in the "incoming" directory:
cp ${tmpdir}/python3-dali_* ~packages/incoming/
To build packages to upload to PyPI:
cd ${pkgdir}
python3 setup.py sdist bdist_wheel
twine check dist/*
twine upload dist/*
EOF