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.

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