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.

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