publish.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env bash
  2. set -eu
  3. cd "$(dirname "$0")/../.."
  4. VERSION="$1"
  5. DATE=$(date +%F)
  6. TAG="v$VERSION"
  7. VERSION_REGEX="[0-9a-z\\.\\-]+"
  8. update_version_in_source () {
  9. IFS=".-" read MAJOR MINOR REVISION EXTRA < <(echo "$VERSION")
  10. UNDERLINE=$(printf -- '-%.0s' $(seq 1 ${#TAG}))
  11. sed -i~ -bE "s/version=$VERSION_REGEX/version=$VERSION/; s|ardu-badge.com/ArduinoJson/$VERSION_REGEX|ardu-badge.com/ArduinoJson/$VERSION|; " README.md
  12. rm README.md~
  13. sed -i~ -bE "4s/HEAD/$TAG ($DATE)/; 5s/-+/$UNDERLINE/" CHANGELOG.md
  14. rm CHANGELOG.md~
  15. sed -i~ -bE "s/(project\\s*\\(ArduinoJson\\s+VERSION\\s+).*?\\)/\\1$MAJOR.$MINOR.$REVISION)/" CMakeLists.txt
  16. rm CMakeLists.txt~
  17. sed -i~ -bE "s/\"version\":.*$/\"version\": \"$VERSION\",/" library.json
  18. rm library.json~
  19. sed -i~ -bE "s/version=.*$/version=$VERSION/" library.properties
  20. rm library.properties~
  21. sed -i~ -bE "s/version: .*$/version: $VERSION.{build}/" appveyor.yml
  22. rm appveyor.yml~
  23. sed -i~ -bE \
  24. -e "s/ARDUINOJSON_VERSION .*$/ARDUINOJSON_VERSION \"$VERSION\"/" \
  25. -e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \
  26. -e "s/ARDUINOJSON_VERSION_MINOR .*$/ARDUINOJSON_VERSION_MINOR $MINOR/" \
  27. -e "s/ARDUINOJSON_VERSION_REVISION .*$/ARDUINOJSON_VERSION_REVISION $REVISION/" \
  28. src/ArduinoJson/version.hpp
  29. rm src/ArduinoJson/version.hpp*~
  30. }
  31. commit_new_version () {
  32. git add src/ArduinoJson/version.hpp README.md CHANGELOG.md library.json library.properties appveyor.yml CMakeLists.txt
  33. git commit -m "Set version to $VERSION"
  34. }
  35. add_tag () {
  36. CHANGES=$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' CHANGELOG.md)
  37. git tag -m "ArduinoJson $VERSION"$'\n'"$CHANGES" "$TAG"
  38. }
  39. push () {
  40. git push --follow-tags
  41. }
  42. update_version_in_source
  43. commit_new_version
  44. add_tag
  45. push
  46. extras/scripts/build-arduino-package.sh
  47. extras/scripts/build-single-header.sh
  48. extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"