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.

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