logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

release.sh (5074B)


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