re-worked release workflow, it is one-step and creates GPG signatures now
[youtube-dl] / devscripts / release.sh
1 #!/bin/sh
2
3 # IMPORTANT: the following assumptions are made
4 # * you did --set-upstream
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 set -e
12
13 if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi
14 version="$1"
15 if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi
16 if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi
17 if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
18
19 echo "\n### First of all, testing..."
20 make clean
21 nosetests --with-coverage --cover-package=youtube_dl --cover-html test || exit 1
22
23 echo "\n### Changing version in version.py..."
24 sed -i~ "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py
25
26 echo "\n### Committing CHANGELOG README.md and youtube_dl/version.py..."
27 make README.md
28 git add CHANGELOG README.md youtube_dl/version.py
29 git commit -m "release $version"
30
31 echo "\n### Now tagging, signing and pushing..."
32 git tag -s -m "Release $version" "$version"
33 git show "$version"
34 read -p "Is it good, can I push? (y/n) " -n 1
35 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
36 echo
37 git push
38
39 echo "\n### OK, now it is time to build the binaries..."
40 REV=$(git rev-parse HEAD)
41 make youtube-dl youtube-dl.tar.gz
42 wget "http://jeromelaheurte.net:8142/download/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe || \
43         wget "http://jeromelaheurte.net:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe
44 mkdir -p "update_staging/$version"
45 mv youtube-dl youtube-dl.exe "update_staging/$version"
46 mv youtube-dl.tar.gz "update_staging/$version/youtube-dl-$version.tar.gz"
47 git checkout HEAD -- youtube-dl youtube-dl.exe
48
49 echo "\n### Signing and uploading the new binaries to youtube-dl.org..."
50 for f in update_staging/$version/*; do gpg --detach-sig "$f"; done
51 scp -r "update_staging/$version" ytdl@youtube-dl.org:html/downloads/
52 rm -r update_staging
53
54 echo "\n### Now switching to gh-pages..."
55 MASTER=$(git rev-parse --abbrev-ref HEAD)
56 git checkout gh-pages
57 git checkout "$MASTER" -- devscripts/gh-pages/
58 git reset devscripts/gh-pages/
59 devscripts/gh-pages/add-version.py $version
60 devscripts/gh-pages/sign-versions.py < updates_key.pem
61 devscripts/gh-pages/generate-download.py
62 devscripts/gh-pages/update-copyright.py
63 rm -r test_coverage
64 mv cover test_coverage
65 git add *.html *.html.in update test_coverage
66 git commit -m "release $version"
67 git show HEAD
68 read -p "Is it good, can I push? (y/n) " -n 1
69 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
70 echo
71 git push
72
73 echo "\n### DONE!"
74 git checkout $MASTER