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
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2017-03-31 17:04:44 +02:00
|
|
|
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}
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2017-03-20 13:39:43 +01:00
|
|
|
sed -i "s#\"${PYVERSION}\"#\"${NEWVERSION}\"#" "gallery_dl/version.py"
|
2019-11-26 12:05:31 +01:00
|
|
|
sed -i "s#v[0-9]\.[0-9]\+\.[0-9]\+#v${NEWVERSION}#" "${README}"
|
2019-11-09 00:00:40 +01:00
|
|
|
make man
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
update-dev() {
|
|
|
|
cd "${ROOTDIR}"
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2017-03-31 17:04:44 +02:00
|
|
|
IFS="." read MAJOR MINOR BUILD <<< "${NEWVERSION}"
|
|
|
|
BUILD=$((BUILD+1))
|
2022-03-14 13:04:14 +01:00
|
|
|
|
2017-11-08 17:42:54 +01:00
|
|
|
# update version to -dev
|
2017-03-31 17:04:44 +02:00
|
|
|
sed -i "s#\"${NEWVERSION}\"#\"${MAJOR}.${MINOR}.${BUILD}-dev\"#" "gallery_dl/version.py"
|
2017-11-08 17:42:54 +01:00
|
|
|
|
2022-03-14 13:04:14 +01:00
|
|
|
git add "gallery_dl/version.py"
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
2019-04-17 12:44:45 +02:00
|
|
|
build-python() {
|
2017-03-20 13:39:43 +01:00
|
|
|
cd "${ROOTDIR}"
|
2024-04-03 19:33:14 +02:00
|
|
|
echo Building sdist and wheel
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2024-04-03 19:33:14 +02:00
|
|
|
python -m build
|
2017-06-28 09:42:49 +02:00
|
|
|
}
|
2017-03-20 13:39:43 +01:00
|
|
|
|
2019-04-17 12:44:45 +02:00
|
|
|
build-linux() {
|
2018-03-17 15:35:38 +01:00
|
|
|
cd "${ROOTDIR}"
|
2019-04-17 12:44:45 +02:00
|
|
|
echo Building Linux executable
|
|
|
|
|
2024-03-11 21:35:50 +01:00
|
|
|
build-vm 'ubuntu22.04' 'gallery-dl.bin'
|
2019-04-17 12:44:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
build-windows() {
|
2024-03-11 21:35:50 +01:00
|
|
|
cd "${ROOTDIR}"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Building Windows executable
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2024-03-11 21:35:50 +01:00
|
|
|
build-vm 'windows7_x86_sp1' 'gallery-dl.exe'
|
|
|
|
}
|
|
|
|
|
|
|
|
build-vm() {
|
|
|
|
VMNAME="$1"
|
|
|
|
BINNAME="$2"
|
|
|
|
TMPPATH="/tmp/gallery-dl/dist/$BINNAME"
|
2019-04-17 12:44:45 +02:00
|
|
|
|
2024-03-11 21:35:50 +01:00
|
|
|
# launch VM
|
|
|
|
vmstart "$VMNAME" &
|
2017-03-20 13:39:43 +01:00
|
|
|
disown
|
2024-03-11 21:35:50 +01:00
|
|
|
|
|
|
|
# copy source files
|
|
|
|
mkdir -p /tmp/gallery-dl
|
|
|
|
cp -a -t /tmp/gallery-dl -- \
|
|
|
|
./gallery_dl ./scripts ./data ./setup.py ./README.rst
|
|
|
|
|
|
|
|
# remove old executable
|
|
|
|
rm -f "./dist/$BINNAME"
|
|
|
|
|
|
|
|
# wait for new executable
|
|
|
|
while [ ! -e "$TMPPATH" ] ; do
|
2017-03-20 13:39:43 +01:00
|
|
|
sleep 5
|
|
|
|
done
|
2019-04-17 12:44:45 +02:00
|
|
|
sleep 2
|
2024-03-11 21:35:50 +01:00
|
|
|
|
|
|
|
# move
|
|
|
|
mv "$TMPPATH" "./dist/$BINNAME"
|
|
|
|
|
|
|
|
rm -r /tmp/gallery-dl
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sign() {
|
|
|
|
cd "${ROOTDIR}/dist"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Signing files
|
2018-03-17 15:35:38 +01:00
|
|
|
|
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
|
2019-04-17 12:44:45 +02:00
|
|
|
gpg --detach-sign --yes gallery-dl.exe
|
|
|
|
gpg --detach-sign --yes gallery-dl.bin
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
2017-11-08 17:42:54 +01:00
|
|
|
changelog() {
|
|
|
|
cd "${ROOTDIR}"
|
|
|
|
echo Updating "${CHANGELOG}"
|
|
|
|
|
2019-04-17 12:44:45 +02:00
|
|
|
# - replace "#NN" with link to actual issue
|
|
|
|
# - insert new version and date
|
2017-11-08 17:42:54 +01:00
|
|
|
sed -i \
|
|
|
|
-e "s*\([( ]\)#\([0-9]\+\)*\1[#\2](https://github.com/mikf/gallery-dl/issues/\2)*g" \
|
2022-03-14 13:04:14 +01:00
|
|
|
-e "s*^## \w\+\$*## ${NEWVERSION} - $(date +%Y-%m-%d)*" \
|
2017-11-08 17:42:54 +01:00
|
|
|
"${CHANGELOG}"
|
|
|
|
}
|
|
|
|
|
2018-03-17 15:35:38 +01:00
|
|
|
supportedsites() {
|
|
|
|
cd "${ROOTDIR}"
|
|
|
|
echo Checking if "${SUPPORTEDSITES}" is up to date
|
|
|
|
|
2019-03-24 10:36:33 +01:00
|
|
|
./scripts/supportedsites.py
|
2018-03-17 15:35:38 +01:00
|
|
|
if ! git diff --quiet "${SUPPORTEDSITES}"; then
|
|
|
|
echo "updated ${SUPPORTEDSITES} contains changes"
|
|
|
|
exit 4
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-12-26 19:01:35 +01:00
|
|
|
upload-git() {
|
2017-03-20 13:39:43 +01:00
|
|
|
cd "${ROOTDIR}"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Pushing changes to github
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2017-11-08 17:42:54 +01:00
|
|
|
git add "gallery_dl/version.py" "${README}" "${CHANGELOG}"
|
2017-03-20 13:39:43 +01:00
|
|
|
git commit -S -m "release version ${NEWVERSION}"
|
|
|
|
git tag -s -m "version ${NEWVERSION}" "v${NEWVERSION}"
|
2020-12-26 19:01:35 +01:00
|
|
|
git push --atomic origin master "v${NEWVERSION}"
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
2020-12-26 19:01:35 +01:00
|
|
|
upload-pypi() {
|
2017-03-20 13:39:43 +01:00
|
|
|
cd "${ROOTDIR}/dist"
|
2017-03-31 17:04:44 +02:00
|
|
|
echo Uploading to PyPI
|
2018-03-17 15:35:38 +01:00
|
|
|
|
2017-03-31 17:04:44 +02:00
|
|
|
twine upload gallery_dl-${NEWVERSION}*
|
2017-03-20 13:39:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ROOTDIR="$(realpath "$(dirname "$0")/..")/"
|
2017-11-08 17:42:54 +01:00
|
|
|
README="README.rst"
|
|
|
|
CHANGELOG="CHANGELOG.md"
|
2021-03-12 03:03:48 +01:00
|
|
|
SUPPORTEDSITES="./docs/supportedsites.md"
|
2017-03-20 13:39:43 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2017-11-08 17:42:54 +01:00
|
|
|
if [[ ! $NEWVERSION =~ [0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9]+)?)?$ ]]; then
|
2017-03-20 13:39:43 +01:00
|
|
|
echo "invalid version: $NEWVERSION"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
prompt
|
2018-03-17 15:35:38 +01:00
|
|
|
supportedsites
|
2017-03-31 17:04:44 +02:00
|
|
|
cleanup
|
2017-03-20 13:39:43 +01:00
|
|
|
update
|
2020-06-27 19:45:09 +02:00
|
|
|
changelog
|
2019-04-17 12:44:45 +02:00
|
|
|
build-python
|
|
|
|
build-linux
|
2018-03-17 15:35:38 +01:00
|
|
|
build-windows
|
2017-03-20 13:39:43 +01:00
|
|
|
sign
|
2020-12-26 19:01:35 +01:00
|
|
|
upload-pypi
|
2023-12-02 13:56:21 +01:00
|
|
|
upload-git
|
2017-03-20 13:39:43 +01:00
|
|
|
update-dev
|