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