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