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