release.sh 4.9 KB

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