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