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
9 # pip install coverage nose rsa
13 # make hash on local files
18 if [ "$1" = '--run-tests' ]; then
23 if [ -z "$1" ]; then echo "ERROR: specify version number like this: $0 1994.09.06"; exit 1; fi
25 major_version=$(echo "$version" | sed -n 's#^\([0-9]*\.[0-9]*\.[0-9]*\).*#\1#p')
26 if test "$major_version" '!=' "$(date '+%Y.%m.%d')"; then
27 echo "$version does not start with today's date!"
31 if [ ! -z "`git tag | grep "$version"`" ]; then echo 'ERROR: version already present'; exit 1; fi
32 if [ ! -z "`git status --porcelain | grep -v CHANGELOG`" ]; then echo 'ERROR: the working directory is not clean; commit or stash changes'; exit 1; fi
33 useless_files=$(find youtube_dl -type f -not -name '*.py')
34 if [ ! -z "$useless_files" ]; then echo "ERROR: Non-.py files in youtube_dl: $useless_files"; exit 1; fi
35 if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
37 /bin/echo -e "\n### First of all, testing..."
42 nosetests --verbose --with-coverage --cover-package=youtube_dl --cover-html test --stop || exit 1
45 /bin/echo -e "\n### Changing version in version.py..."
46 sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py
48 /bin/echo -e "\n### Committing documentation and youtube_dl/version.py..."
49 make README.md CONTRIBUTING.md supportedsites
50 git add README.md CONTRIBUTING.md docs/supportedsites.md youtube_dl/version.py
51 git commit -m "release $version"
53 /bin/echo -e "\n### Now tagging, signing and pushing..."
54 git tag -s -m "Release $version" "$version"
56 read -p "Is it good, can I push? (y/n) " -n 1
57 if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
59 MASTER=$(git rev-parse --abbrev-ref HEAD)
60 git push origin $MASTER:master
61 git push origin "$version"
63 /bin/echo -e "\n### OK, now it is time to build the binaries..."
64 REV=$(git rev-parse HEAD)
65 make youtube-dl youtube-dl.tar.gz
66 read -p "VM running? (y/n) " -n 1
67 wget "http://localhost:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe
68 mkdir -p "build/$version"
69 mv youtube-dl youtube-dl.exe "build/$version"
70 mv youtube-dl.tar.gz "build/$version/youtube-dl-$version.tar.gz"
71 RELEASE_FILES="youtube-dl youtube-dl.exe youtube-dl-$version.tar.gz"
72 (cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
73 (cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
74 (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
75 (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
77 /bin/echo -e "\n### Signing and uploading the new binaries to yt-dl.org ..."
78 for f in $RELEASE_FILES; do gpg --passphrase-repeat 5 --detach-sig "build/$version/$f"; done
79 scp -r "build/$version" ytdl@yt-dl.org:html/tmp/
80 ssh ytdl@yt-dl.org "mv html/tmp/$version html/downloads/"
81 ssh ytdl@yt-dl.org "sh html/update_latest.sh $version"
83 /bin/echo -e "\n### Now switching to gh-pages..."
84 git clone --branch gh-pages --single-branch . build/gh-pages
88 ORIGIN_URL=$(git config --get remote.origin.url)
90 "$ROOT/devscripts/gh-pages/add-version.py" $version
91 "$ROOT/devscripts/gh-pages/update-feed.py"
92 "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
93 "$ROOT/devscripts/gh-pages/generate-download.py"
94 "$ROOT/devscripts/gh-pages/update-copyright.py"
95 "$ROOT/devscripts/gh-pages/update-sites.py"
96 git add *.html *.html.in update
97 git commit -m "release $version"
98 git push "$ROOT" gh-pages
99 git push "$ORIGIN_URL" gh-pages
104 echo "Uploading to PyPi ..."
105 python setup.py sdist bdist_wheel upload
108 /bin/echo -e "\n### DONE!"