A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

168 rindas
4.9 KiB

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