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

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