2017-03-20 13:39:43 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
prompt() {
|
|
|
|
echo "root: ${ROOTDIR} old: ${OLDVERSION} - new: ${NEWVERSION}"
|
|
|
|
read -n 1 -r -p "Proceed? [Y/n] " P
|
|
|
|
echo
|
|
|
|
if [ "$P" == y -o "$P" == Y -o -z "$P" ]; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-31 17:04:44 +02:00
|
|
|
cleanup() {
|
|
|
|
cd "${ROOTDIR}"
|
|
|
|
echo Removing old build directory
|
|
|
|
if [ -d ./build ]; then
|
|
|
|
rm -rf ./build
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-03-20 13:39:43 +01:00
|
|
|
update() {
|
|
|
|
cd "${ROOTDIR}"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Updating version to ${NEWVERSION}
|
2017-03-20 13:39:43 +01:00
|
|
|
sed -i "s#\"${PYVERSION}\"#\"${NEWVERSION}\"#" "gallery_dl/version.py"
|
2017-05-22 08:47:58 +02:00
|
|
|
sed -i "s#v${OLDVERSION}#v${NEWVERSION}#" "README.rst"
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
update-dev() {
|
|
|
|
cd "${ROOTDIR}"
|
2017-03-31 17:04:44 +02:00
|
|
|
IFS="." read MAJOR MINOR BUILD <<< "${NEWVERSION}"
|
|
|
|
BUILD=$((BUILD+1))
|
|
|
|
sed -i "s#\"${NEWVERSION}\"#\"${MAJOR}.${MINOR}.${BUILD}-dev\"#" "gallery_dl/version.py"
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
cd "${ROOTDIR}"
|
|
|
|
|
|
|
|
# build wheel and source distributions
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Building bdist_wheel and sdist
|
2017-03-20 13:39:43 +01:00
|
|
|
python setup.py bdist_wheel sdist
|
2017-06-28 09:42:49 +02:00
|
|
|
}
|
2017-03-20 13:39:43 +01:00
|
|
|
|
2017-06-28 09:42:49 +02:00
|
|
|
build_windows() {
|
2017-03-20 13:39:43 +01:00
|
|
|
# build windows exe in vm
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Building Windows executable
|
2017-03-20 13:39:43 +01:00
|
|
|
ln -fs "${ROOTDIR}" /tmp/
|
|
|
|
vmstart "Windows 7" &
|
|
|
|
disown
|
2017-03-31 17:04:44 +02:00
|
|
|
while [ ! -e "gallery-dl.exe" ] ; do
|
2017-03-20 13:39:43 +01:00
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
# check exe version
|
|
|
|
OUTPUT="$(wine gallery-dl.exe --version)"
|
|
|
|
if [[ ! "${OUTPUT%?}" == "${NEWVERSION}" ]]; then
|
|
|
|
echo "exe version mismatch: ${OUTPUT} != ${NEWVERSION}"
|
|
|
|
exit 3
|
|
|
|
fi
|
2017-03-31 17:04:44 +02:00
|
|
|
if [ -e "dist/gallery-dl.exe" ]; then
|
|
|
|
mv -f "dist/gallery-dl.exe" "dist/gallery-v${OLDVERSION}-dl.exe"
|
|
|
|
fi
|
2017-03-20 13:39:43 +01:00
|
|
|
mv "gallery-dl.exe" "./dist/"
|
|
|
|
}
|
|
|
|
|
|
|
|
sign() {
|
|
|
|
cd "${ROOTDIR}/dist"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Signing files
|
2017-03-20 13:39:43 +01:00
|
|
|
gpg --detach-sign --armor gallery_dl-${NEWVERSION}-py3-none-any.whl
|
|
|
|
gpg --detach-sign --armor gallery_dl-${NEWVERSION}.tar.gz
|
|
|
|
gpg --detach-sign gallery-dl.exe
|
|
|
|
}
|
|
|
|
|
|
|
|
git-upload() {
|
|
|
|
cd "${ROOTDIR}"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Pushing changes to github
|
2017-03-20 13:39:43 +01:00
|
|
|
git add "gallery_dl/version.py" "README.rst"
|
|
|
|
git commit -S -m "release version ${NEWVERSION}"
|
|
|
|
git tag -s -m "version ${NEWVERSION}" "v${NEWVERSION}"
|
2017-03-31 17:04:44 +02:00
|
|
|
git push
|
|
|
|
git push origin "v${NEWVERSION}"
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pypi-upload() {
|
|
|
|
cd "${ROOTDIR}/dist"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Uploading to PyPI
|
|
|
|
twine upload gallery_dl-${NEWVERSION}*
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ROOTDIR="$(realpath "$(dirname "$0")/..")/"
|
|
|
|
|
|
|
|
LASTTAG="$(git describe --abbrev=0 --tags)"
|
|
|
|
OLDVERSION="${LASTTAG#v}"
|
|
|
|
PYVERSION="$(python -c "import gallery_dl as g; print(g.__version__)")"
|
|
|
|
|
|
|
|
if [[ "$1" ]]; then
|
|
|
|
NEWVERSION="$1"
|
|
|
|
else
|
|
|
|
NEWVERSION="${PYVERSION%-dev}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $NEWVERSION =~ [0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
|
|
echo "invalid version: $NEWVERSION"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
prompt
|
2017-03-31 17:04:44 +02:00
|
|
|
cleanup
|
2017-03-20 13:39:43 +01:00
|
|
|
update
|
|
|
|
build
|
2017-06-28 09:42:49 +02:00
|
|
|
build_windows
|
2017-03-20 13:39:43 +01:00
|
|
|
sign
|
|
|
|
git-upload
|
|
|
|
pypi-upload
|
|
|
|
update-dev
|