A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

173 строки
4.9 KiB

  1. #! /usr/bin/env bash
  2. if [[ -z "$1" ]]; then
  3. echo "usage: $0 1.2.3"
  4. exit 1
  5. fi
  6. VERSION=$1
  7. SCRIPT_DIR=$(dirname "$0")
  8. RELEASE_DATE=$(date +"%B %d, %Y")
  9. check_git() {
  10. if [[ -n "$(git status --porcelain --untracked-files=no)" ]]; then
  11. echo "Aborting: dirty working directory."
  12. exit 1
  13. fi
  14. if [[ "$(git rev-parse --abbrev-ref HEAD)" != "develop" ]]; then
  15. echo "Aborting: not on develop."
  16. exit 1
  17. fi
  18. echo -n "Are you absolutely ready to release? [yN] "
  19. read confirm
  20. if [[ ${confirm,,} != "y" ]]; then
  21. exit 1
  22. fi
  23. }
  24. update_version() {
  25. echo -n "Updating mwparserfromhell.__version__..."
  26. sed -e 's/__version__ = .*/__version__ = "'$VERSION'"/' -i "" mwparserfromhell/__init__.py
  27. echo " done."
  28. }
  29. update_appveyor() {
  30. filename="appveyor.yml"
  31. echo -n "Updating $filename..."
  32. sed -e "s/version: .*/version: $VERSION-b{build}/" -i "" $filename
  33. echo " done."
  34. }
  35. update_changelog() {
  36. filename="CHANGELOG"
  37. echo -n "Updating $filename..."
  38. sed -e "1s/.*/v$VERSION (released $RELEASE_DATE):/" -i "" $filename
  39. echo " done."
  40. }
  41. update_docs_changelog() {
  42. filename="docs/changelog.rst"
  43. echo -n "Updating $filename..."
  44. dashes=$(seq 1 $(expr ${#VERSION} + 1) | sed 's/.*/-/' | tr -d '\n')
  45. previous_lineno=$(expr $(grep -n -e "^---" $filename | sed '2q;d' | cut -d ':' -f 1) - 1)
  46. previous_version=$(sed $previous_lineno'q;d' $filename)
  47. sed \
  48. -e "4s/.*/v$VERSION/" \
  49. -e "5s/.*/$dashes/" \
  50. -e "7s/.*/\`Released $RELEASE_DATE <https:\/\/github.com\/earwig\/mwparserfromhell\/tree\/v$VERSION>\`_/" \
  51. -e "8s/.*/(\`changes <https:\/\/github.com\/earwig\/mwparserfromhell\/compare\/$previous_version...v$VERSION>\`__):/" \
  52. -i "" $filename
  53. echo " done."
  54. }
  55. do_git_stuff() {
  56. echo -n "Git: committing, tagging, and merging release..."
  57. git commit -qam "release/$VERSION"
  58. git tag v$VERSION -s -m "version $VERSION"
  59. git checkout -q master
  60. git merge -q --no-ff develop -m "Merge branch 'develop'"
  61. echo -n " pushing..."
  62. git push -q --tags origin master
  63. git checkout -q develop
  64. git push -q origin develop
  65. echo " done."
  66. }
  67. upload_to_pypi() {
  68. echo -n "PyPI: uploading source tarball and docs..."
  69. python setup.py -q register sdist upload -s
  70. python setup.py -q upload_docs
  71. echo " done."
  72. }
  73. windows_build() {
  74. echo "PyPI: building/uploading Windows binaries..."
  75. echo "*** Run in Windows: ./scripts/win_build.py"
  76. echo "*** Press enter when done."
  77. read
  78. }
  79. post_release() {
  80. echo
  81. echo "*** Release completed."
  82. echo "*** Update: https://github.com/earwig/mwparserfromhell/releases/tag/v$VERSION"
  83. echo "*** Verify: https://pypi.python.org/pypi/mwparserfromhell"
  84. echo "*** Verify: https://mwparserfromhell.readthedocs.org"
  85. echo "*** Press enter to sanity-check the release."
  86. read
  87. }
  88. test_release() {
  89. echo
  90. echo "Checking mwparserfromhell v$VERSION..."
  91. echo -n "Creating a virtualenv..."
  92. virtdir="mwparser-test-env"
  93. virtualenv -q $virtdir
  94. cd $virtdir
  95. source bin/activate
  96. echo " done."
  97. echo -n "Installing mwparserfromhell with pip..."
  98. pip -q install mwparserfromhell
  99. echo " done."
  100. echo -n "Checking version..."
  101. reported_version=$(python -c 'print __import__("mwparserfromhell").__version__')
  102. if [[ "$reported_version" != "$VERSION" ]]; then
  103. echo " error."
  104. echo "*** ERROR: mwparserfromhell is reporting its version as $reported_version, not $VERSION!"
  105. deactivate
  106. cd ..
  107. rm -rf $virtdir
  108. exit 1
  109. else
  110. echo " done."
  111. fi
  112. pip -q uninstall -y mwparserfromhell
  113. echo -n "Downloading mwparserfromhell source tarball and GPG signature..."
  114. curl -sL "https://pypi.python.org/packages/source/m/mwparserfromhell/mwparserfromhell-$VERSION.tar.gz" -o "mwparserfromhell.tar.gz"
  115. curl -sL "https://pypi.python.org/packages/source/m/mwparserfromhell/mwparserfromhell-$VERSION.tar.gz.asc" -o "mwparserfromhell.tar.gz.asc"
  116. echo " done."
  117. echo "Verifying tarball..."
  118. gpg --verify mwparserfromhell.tar.gz.asc
  119. if [[ "$?" != "0" ]]; then
  120. echo "*** ERROR: GPG signature verification failed!"
  121. deactivate
  122. cd ..
  123. rm -rf $virtdir
  124. exit 1
  125. fi
  126. tar -xf mwparserfromhell.tar.gz
  127. rm mwparserfromhell.tar.gz mwparserfromhell.tar.gz.asc
  128. cd mwparserfromhell-$VERSION
  129. echo "Running unit tests..."
  130. python setup.py -q test
  131. if [[ "$?" != "0" ]]; then
  132. echo "*** ERROR: Unit tests failed!"
  133. deactivate
  134. cd ../..
  135. rm -rf $virtdir
  136. exit 1
  137. fi
  138. echo -n "Everything looks good. Cleaning up..."
  139. deactivate
  140. cd ../..
  141. rm -rf $virtdir
  142. echo " done."
  143. }
  144. echo "Preparing mwparserfromhell v$VERSION..."
  145. cd "$SCRIPT_DIR/.."
  146. check_git
  147. update_version
  148. update_appveyor
  149. update_changelog
  150. update_docs_changelog
  151. do_git_stuff
  152. upload_to_pypi
  153. windows_build
  154. post_release
  155. test_release
  156. echo "All done."
  157. exit 0