Correct comparison test
[youtube-dl] / devscripts / release.sh
1 #!/bin/bash
2
3 # IMPORTANT: the following assumptions are made
4 # * the GH repo is on the origin remote
5 # * the gh-pages branch is named so locally
6 # * the git config user.signingkey is properly set
7
8 # You will need
9 # pip install coverage nose rsa
10
11 # TODO
12 # release notes
13 # make hash on local files
14
15 set -e
16
17 skip_test=false
18 if [ "$2" = '--skip-test' ]; then
19     skip_test=true
20 fi
21 if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi
22 version="$1"
23 if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi
24 if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi
25 if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
26
27 /bin/echo -e "\n### First of all, testing..."
28 make cleanall
29 if $skip_tests; then
30     echo 'SKIPPING TESTS'
31 else
32     nosetests --verbose --with-coverage --cover-package=youtube_dl --cover-html test --stop || exit 1
33 fi
34
35 /bin/echo -e "\n### Changing version in version.py..."
36 sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py
37
38 /bin/echo -e "\n### Committing CHANGELOG README.md and youtube_dl/version.py..."
39 make README.md
40 git add CHANGELOG README.md youtube_dl/version.py
41 git commit -m "release $version"
42
43 /bin/echo -e "\n### Now tagging, signing and pushing..."
44 git tag -s -m "Release $version" "$version"
45 git show "$version"
46 read -p "Is it good, can I push? (y/n) " -n 1
47 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
48 echo
49 MASTER=$(git rev-parse --abbrev-ref HEAD)
50 git push origin $MASTER:master
51 git push origin "$version"
52
53 /bin/echo -e "\n### OK, now it is time to build the binaries..."
54 REV=$(git rev-parse HEAD)
55 make youtube-dl youtube-dl.tar.gz
56 wget "http://jeromelaheurte.net:8142/download/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe || \
57         wget "http://jeromelaheurte.net:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe
58 mkdir -p "build/$version"
59 mv youtube-dl youtube-dl.exe "build/$version"
60 mv youtube-dl.tar.gz "build/$version/youtube-dl-$version.tar.gz"
61 RELEASE_FILES="youtube-dl youtube-dl.exe youtube-dl-$version.tar.gz"
62 (cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
63 (cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
64 (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
65 (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
66 git checkout HEAD -- youtube-dl youtube-dl.exe
67
68 /bin/echo -e "\n### Signing and uploading the new binaries to youtube-dl.org..."
69 for f in $RELEASE_FILES; do gpg --detach-sig "build/$version/$f"; done
70 scp -r "build/$version" ytdl@youtube-dl.org:html/downloads/
71
72 /bin/echo -e "\n### Now switching to gh-pages..."
73 git clone --branch gh-pages --single-branch . build/gh-pages
74 ROOT=$(pwd)
75 (
76     set -e
77     ORIGIN_URL=$(git config --get remote.origin.url)
78     cd build/gh-pages
79     "$ROOT/devscripts/gh-pages/add-version.py" $version
80     "$ROOT/devscripts/gh-pages/update-feed.py"
81     "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
82     "$ROOT/devscripts/gh-pages/generate-download.py"
83     "$ROOT/devscripts/gh-pages/update-copyright.py"
84     git add *.html *.html.in update
85     git commit -m "release $version"
86     git show HEAD
87     read -p "Is it good, can I push? (y/n) " -n 1
88     if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
89     echo
90     git push "$ROOT" gh-pages
91     git push "$ORIGIN_URL" gh-pages
92 )
93 rm -rf build
94
95 make pypi-files
96 echo "Uploading to PyPi ..."
97 python setup.py sdist upload
98 make clean
99
100 /bin/echo -e "\n### DONE!"