You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.6 KiB

12 years ago
  1. #!/bin/bash
  2. # IMPORTANT: the following assumptions are made
  3. # * the GH repo is on the origin remote
  4. # * the gh-pages branch is named so locally
  5. # * the git config user.signingkey is properly set
  6. # You will need
  7. # pip install coverage nose rsa
  8. # TODO
  9. # release notes
  10. # make hash on local files
  11. set -e
  12. skip_tests=false
  13. if [ "$1" = '--skip-test' ]; then
  14. skip_tests=true
  15. shift
  16. fi
  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. /bin/echo -e "\n### First of all, testing..."
  23. make cleanall
  24. if $skip_tests ; then
  25. echo 'SKIPPING TESTS'
  26. else
  27. nosetests --verbose --with-coverage --cover-package=youtube_dl --cover-html test --stop || exit 1
  28. fi
  29. /bin/echo -e "\n### Changing version in version.py..."
  30. sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py
  31. /bin/echo -e "\n### Committing CHANGELOG README.md and youtube_dl/version.py..."
  32. make README.md
  33. git add CHANGELOG README.md youtube_dl/version.py
  34. git commit -m "release $version"
  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. /bin/echo -e "\n### OK, now it is time to build the binaries..."
  45. REV=$(git rev-parse HEAD)
  46. make youtube-dl youtube-dl.tar.gz
  47. wget "http://jeromelaheurte.net:8142/download/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe || \
  48. wget "http://jeromelaheurte.net:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe
  49. mkdir -p "build/$version"
  50. mv youtube-dl youtube-dl.exe "build/$version"
  51. mv youtube-dl.tar.gz "build/$version/youtube-dl-$version.tar.gz"
  52. RELEASE_FILES="youtube-dl youtube-dl.exe youtube-dl-$version.tar.gz"
  53. (cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
  54. (cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
  55. (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
  56. (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
  57. git checkout HEAD -- youtube-dl youtube-dl.exe
  58. /bin/echo -e "\n### Signing and uploading the new binaries to youtube-dl.org..."
  59. for f in $RELEASE_FILES; do gpg --detach-sig "build/$version/$f"; done
  60. scp -r "build/$version" ytdl@yt-dl.org:html/tmp/
  61. ssh ytdl@yt-dl.org "mv html/tmp/$version html/downloads/"
  62. /bin/echo -e "\n### Now switching to gh-pages..."
  63. git clone --branch gh-pages --single-branch . build/gh-pages
  64. ROOT=$(pwd)
  65. (
  66. set -e
  67. ORIGIN_URL=$(git config --get remote.origin.url)
  68. cd build/gh-pages
  69. "$ROOT/devscripts/gh-pages/add-version.py" $version
  70. "$ROOT/devscripts/gh-pages/update-feed.py"
  71. "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
  72. "$ROOT/devscripts/gh-pages/generate-download.py"
  73. "$ROOT/devscripts/gh-pages/update-copyright.py"
  74. git add *.html *.html.in update
  75. git commit -m "release $version"
  76. git show HEAD
  77. read -p "Is it good, can I push? (y/n) " -n 1
  78. if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
  79. echo
  80. git push "$ROOT" gh-pages
  81. git push "$ORIGIN_URL" gh-pages
  82. )
  83. rm -rf build
  84. make pypi-files
  85. echo "Uploading to PyPi ..."
  86. python setup.py sdist upload
  87. make clean
  88. /bin/echo -e "\n### DONE!"