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=true
  13. if [ "$1" = '--run-tests' ]; then
  14. skip_tests=false
  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. useless_files=$(find youtube_dl -type f -not -name '*.py')
  22. if [ ! -z "$useless_files" ]; then echo "ERROR: Non-.py files in youtube_dl: $useless_files"; exit 1; fi
  23. if [ ! -f "updates_key.pem" ]; then echo 'ERROR: updates_key.pem missing'; exit 1; fi
  24. /bin/echo -e "\n### First of all, testing..."
  25. make cleanall
  26. if $skip_tests ; then
  27. echo 'SKIPPING TESTS'
  28. else
  29. nosetests --verbose --with-coverage --cover-package=youtube_dl --cover-html test --stop || exit 1
  30. fi
  31. /bin/echo -e "\n### Changing version in version.py..."
  32. sed -i "s/__version__ = '.*'/__version__ = '$version'/" youtube_dl/version.py
  33. /bin/echo -e "\n### Committing CHANGELOG README.md and youtube_dl/version.py..."
  34. make README.md
  35. git add CHANGELOG README.md youtube_dl/version.py
  36. git commit -m "release $version"
  37. /bin/echo -e "\n### Now tagging, signing and pushing..."
  38. git tag -s -m "Release $version" "$version"
  39. git show "$version"
  40. read -p "Is it good, can I push? (y/n) " -n 1
  41. if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
  42. echo
  43. MASTER=$(git rev-parse --abbrev-ref HEAD)
  44. git push origin $MASTER:master
  45. git push origin "$version"
  46. /bin/echo -e "\n### OK, now it is time to build the binaries..."
  47. REV=$(git rev-parse HEAD)
  48. make youtube-dl youtube-dl.tar.gz
  49. read -p "VM running? (y/n) " -n 1
  50. wget "http://localhost:8142/build/rg3/youtube-dl/youtube-dl.exe?rev=$REV" -O youtube-dl.exe
  51. mkdir -p "build/$version"
  52. mv youtube-dl youtube-dl.exe "build/$version"
  53. mv youtube-dl.tar.gz "build/$version/youtube-dl-$version.tar.gz"
  54. RELEASE_FILES="youtube-dl youtube-dl.exe youtube-dl-$version.tar.gz"
  55. (cd build/$version/ && md5sum $RELEASE_FILES > MD5SUMS)
  56. (cd build/$version/ && sha1sum $RELEASE_FILES > SHA1SUMS)
  57. (cd build/$version/ && sha256sum $RELEASE_FILES > SHA2-256SUMS)
  58. (cd build/$version/ && sha512sum $RELEASE_FILES > SHA2-512SUMS)
  59. git checkout HEAD -- youtube-dl youtube-dl.exe
  60. /bin/echo -e "\n### Signing and uploading the new binaries to yt-dl.org ..."
  61. for f in $RELEASE_FILES; do gpg --detach-sig "build/$version/$f"; done
  62. scp -r "build/$version" ytdl@yt-dl.org:html/tmp/
  63. ssh ytdl@yt-dl.org "mv html/tmp/$version html/downloads/"
  64. ssh ytdl@yt-dl.org "sh html/update_latest.sh $version"
  65. /bin/echo -e "\n### Now switching to gh-pages..."
  66. git clone --branch gh-pages --single-branch . build/gh-pages
  67. ROOT=$(pwd)
  68. (
  69. set -e
  70. ORIGIN_URL=$(git config --get remote.origin.url)
  71. cd build/gh-pages
  72. "$ROOT/devscripts/gh-pages/add-version.py" $version
  73. "$ROOT/devscripts/gh-pages/update-feed.py"
  74. "$ROOT/devscripts/gh-pages/sign-versions.py" < "$ROOT/updates_key.pem"
  75. "$ROOT/devscripts/gh-pages/generate-download.py"
  76. "$ROOT/devscripts/gh-pages/update-copyright.py"
  77. "$ROOT/devscripts/gh-pages/update-sites.py"
  78. git add *.html *.html.in update
  79. git commit -m "release $version"
  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!"