]> Raphaƫl G. Git Repositories - youtubedl/blob - devscripts/release.sh
debian/rules: Simplify rules file with use of buildsystem.
[youtubedl] / 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 if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi
18 version="$1"
19 if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi
20 if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi
21 if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
22
23 /bin/echo -e "\n### First of all, testing..."
24 make cleanall
25 nosetests --verbose --with-coverage --cover-package=youtube_dl --cover-html test --stop || exit 1
26
27 /bin/echo -e "\n### Changing version in version.py..."
28 sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py
29
30 /bin/echo -e "\n### Committing CHANGELOG README.md and youtube_dl/version.py..."
31 make README.md
32 git add CHANGELOG README.md youtube_dl/version.py
33 git commit -m "release $version"
34
35 /bin/echo -e "\n### Now tagging, signing and pushing..."
36 git tag -s -m "Release $version" "$version"
37 git show "$version"
38 read -p "Is it good, can I push? (y/n) " -n 1
39 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
40 echo
41 MASTER=$(git rev-parse --abbrev-ref HEAD)
42 git push origin $MASTER:master
43 git push origin "$version"
44
45 /bin/echo -e "\n### OK, now it is time to build the binaries..."
46 REV=$(git rev-parse HEAD)
47 make youtube-dl youtube-dl.tar.gz
48 wget "http://jeromelaheurte.net:8142/download/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe || \
49 wget "http://jeromelaheurte.net:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe
50 mkdir -p "build/$version"
51 mv youtube-dl youtube-dl.exe "build/$version"
52 mv youtube-dl.tar.gz "build/$version/youtube-dl-$version.tar.gz"
53 RELEASE_FILES="youtube-dl youtube-dl.exe youtube-dl-$version.tar.gz"
54 (cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
55 (cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
56 (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
57 (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
58 git checkout HEAD -- youtube-dl youtube-dl.exe
59
60 /bin/echo -e "\n### Signing and uploading the new binaries to youtube-dl.org..."
61 for f in $RELEASE_FILES; do gpg --detach-sig "build/$version/$f"; done
62 scp -r "build/$version" ytdl@youtube-dl.org:html/downloads/
63
64 /bin/echo -e "\n### Now switching to gh-pages..."
65 git clone --branch gh-pages --single-branch . build/gh-pages
66 ROOT=$(pwd)
67 (
68 set -e
69 ORIGIN_URL=$(git config --get remote.origin.url)
70 cd build/gh-pages
71 "$ROOT/devscripts/gh-pages/add-version.py" $version
72 "$ROOT/devscripts/gh-pages/update-feed.py"
73 "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
74 "$ROOT/devscripts/gh-pages/generate-download.py"
75 "$ROOT/devscripts/gh-pages/update-copyright.py"
76 git add *.html *.html.in update
77 git commit -m "release $version"
78 git show HEAD
79 read -p "Is it good, can I push? (y/n) " -n 1
80 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
81 echo
82 git push "$ROOT" gh-pages
83 git push "$ORIGIN_URL" gh-pages
84 )
85 rm -rf build
86
87 make pypi-files
88 echo "Uploading to PyPi ..."
89 python setup.py sdist upload
90 make clean
91
92 /bin/echo -e "\n### DONE!"