]> jfr.im git - yt-dlp.git/blame - devscripts/release.sh
[skip travis] renaming
[yt-dlp.git] / devscripts / release.sh
CommitLineData
55e286ba 1#!/bin/bash
225dceb0 2
b962b76f 3# IMPORTANT: the following assumptions are made
6e3dba16 4# * the GH repo is on the origin remote
b962b76f
FV
5# * the gh-pages branch is named so locally
6# * the git config user.signingkey is properly set
7
8# You will need
f3fb420b 9# pip install coverage nose rsa wheel
b962b76f 10
6e3dba16
FV
11# TODO
12# release notes
13# make hash on local files
14
b962b76f
FV
15set -e
16
0f8f0971 17skip_tests=true
4cef70db 18gpg_sign_commits=""
681b923b
S
19buildserver='localhost:8142'
20
21while true
22do
23case "$1" in
24 --run-tests)
25 skip_tests=false
26 shift
27 ;;
4cef70db
S
28 --gpg-sign-commits|-S)
29 gpg_sign_commits="-S"
30 shift
31 ;;
681b923b
S
32 --buildserver)
33 buildserver="$2"
34 shift 2
35 ;;
36 --*)
37 echo "ERROR: unknown option $1"
38 exit 1
39 ;;
40 *)
41 break
42 ;;
43esac
44done
964ac8b5 45
225dceb0
FV
46if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi
47version="$1"
4c094185
PH
48major_version=$(echo "$version" | sed -n 's#^\([0-9]*\.[0-9]*\.[0-9]*\).*#\1#p')
49if test "$major_version" '!=' "$(date '+%Y.%m.%d')"; then
50 echo "$version does not start with today's date!"
51 exit 1
52fi
53
225dceb0 54if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi
b962b76f 55if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi
cefecac1
U
56useless_files=$(find youtube_dlc -type f -not -name '*.py')
57if [ ! -z "$useless_files" ]; then echo "ERROR: Non-.py files in youtube_dlc: $useless_files"; exit 1; fi
b962b76f 58if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
d2fee3c9
PH
59if ! type pandoc >/dev/null 2>/dev/null; then echo 'ERROR: pandoc is missing'; exit 1; fi
60if ! python3 -c 'import rsa' 2>/dev/null; then echo 'ERROR: python3-rsa is missing'; exit 1; fi
f3fb420b 61if ! python3 -c 'import wheel' 2>/dev/null; then echo 'ERROR: wheel is missing'; exit 1; fi
b962b76f 62
eb87d454 63read -p "Is ChangeLog up to date? (y/n) " -n 1
fc150cba 64if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
eb87d454 65
a72b0f2b 66/bin/echo -e "\n### First of all, testing..."
d200b11c 67make clean
964ac8b5 68if $skip_tests ; then
d71cae62
PH
69 echo 'SKIPPING TESTS'
70else
cefecac1 71 nosetests --verbose --with-coverage --cover-package=youtube_dlc --cover-html test --stop || exit 1
d71cae62 72fi
b962b76f 73
a72b0f2b 74/bin/echo -e "\n### Changing version in version.py..."
cefecac1 75sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dlc/version.py
b962b76f 76
35aa6c53
YCH
77/bin/echo -e "\n### Changing version in ChangeLog..."
78sed -i "s/<unreleased>/$version/" ChangeLog
79
cefecac1 80/bin/echo -e "\n### Committing documentation, templates and youtube_dlc/version.py..."
6f366ef3 81make README.md CONTRIBUTING.md issuetemplates supportedsites
cefecac1 82git add README.md CONTRIBUTING.md .github/ISSUE_TEMPLATE/1_broken_site.md .github/ISSUE_TEMPLATE/2_site_support_request.md .github/ISSUE_TEMPLATE/3_site_feature_request.md .github/ISSUE_TEMPLATE/4_bug_report.md .github/ISSUE_TEMPLATE/5_feature_request.md .github/ISSUE_TEMPLATE/6_question.md docs/supportedsites.md youtube_dlc/version.py ChangeLog
4cef70db 83git commit $gpg_sign_commits -m "release $version"
b962b76f 84
a72b0f2b 85/bin/echo -e "\n### Now tagging, signing and pushing..."
b962b76f
FV
86git tag -s -m "Release $version" "$version"
87git show "$version"
88read -p "Is it good, can I push? (y/n) " -n 1
89if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
90echo
6e3dba16
FV
91MASTER=$(git rev-parse --abbrev-ref HEAD)
92git push origin $MASTER:master
93git push origin "$version"
b962b76f 94
a72b0f2b 95/bin/echo -e "\n### OK, now it is time to build the binaries..."
b962b76f 96REV=$(git rev-parse HEAD)
cefecac1 97make youtube-dlc youtube-dlc.tar.gz
6c603ccc 98read -p "VM running? (y/n) " -n 1
cefecac1 99wget "http://$buildserver/build/ytdl-org/youtube-dl/youtube-dlc.exe?rev=$REV" -O youtube-dlc.exe
09f9552b 100mkdir -p "build/$version"
cefecac1
U
101mv youtube-dlc youtube-dlc.exe "build/$version"
102mv youtube-dlc.tar.gz "build/$version/youtube-dlc-$version.tar.gz"
103RELEASE_FILES="youtube-dlc youtube-dlc.exe youtube-dlc-$version.tar.gz"
09f9552b
PH
104(cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
105(cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
106(cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
107(cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
b962b76f 108
39b32571 109/bin/echo -e "\n### Signing and uploading the new binaries to GitHub..."
cc88b90e 110for f in $RELEASE_FILES; do gpg --passphrase-repeat 5 --detach-sig "build/$version/$f"; done
cad88f96 111
39b32571 112ROOT=$(pwd)
689f31fd 113python devscripts/create-github-release.py ChangeLog $version "$ROOT/build/$version"
cad88f96 114
ea93cce4 115ssh ytdl@yt-dl.org "sh html/update_latest.sh $version"
b962b76f 116
a72b0f2b 117/bin/echo -e "\n### Now switching to gh-pages..."
09f9552b 118git clone --branch gh-pages --single-branch . build/gh-pages
09f9552b
PH
119(
120 set -e
09f9552b 121 ORIGIN_URL=$(git config --get remote.origin.url)
3b83bf8f 122 cd build/gh-pages
09f9552b 123 "$ROOT/devscripts/gh-pages/add-version.py" $version
60607880 124 "$ROOT/devscripts/gh-pages/update-feed.py"
bb289989 125 "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
09f9552b
PH
126 "$ROOT/devscripts/gh-pages/generate-download.py"
127 "$ROOT/devscripts/gh-pages/update-copyright.py"
69100808 128 "$ROOT/devscripts/gh-pages/update-sites.py"
09f9552b 129 git add *.html *.html.in update
4cef70db 130 git commit $gpg_sign_commits -m "release $version"
3b83bf8f 131 git push "$ROOT" gh-pages
bb289989 132 git push "$ORIGIN_URL" gh-pages
09f9552b 133)
253d96f2 134rm -rf build
b962b76f 135
434eb6f2 136make pypi-files
450a30ca 137echo "Uploading to PyPi ..."
4056ad8f 138python setup.py sdist bdist_wheel upload
434eb6f2 139make clean
450a30ca 140
a72b0f2b 141/bin/echo -e "\n### DONE!"