publish.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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/\"version\":.*$/\"version\": \"$VERSION\",/" library.json
  16. rm library.json*~
  17. sed -i~ -bE "s/version=.*$/version=$VERSION/" library.properties
  18. rm library.properties*~
  19. sed -i~ -bE "s/version: .*$/version: $VERSION.{build}/" appveyor.yml
  20. rm appveyor.yml*~
  21. sed -i~ -bE \
  22. -e "s/ARDUINOJSON_VERSION .*$/ARDUINOJSON_VERSION \"$VERSION\"/" \
  23. -e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \
  24. -e "s/ARDUINOJSON_VERSION_MINOR .*$/ARDUINOJSON_VERSION_MINOR $MINOR/" \
  25. -e "s/ARDUINOJSON_VERSION_REVISION .*$/ARDUINOJSON_VERSION_REVISION $REVISION/" \
  26. src/ArduinoJson/version.hpp
  27. rm src/ArduinoJson/version.hpp*~
  28. }
  29. commit_new_version () {
  30. git add src/ArduinoJson/version.hpp README.md CHANGELOG.md library.json library.properties appveyor.yml
  31. git commit -m "Set version to $VERSION"
  32. }
  33. add_tag () {
  34. CHANGES=$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' CHANGELOG.md)
  35. git tag -m "ArduinoJson $VERSION"$'\n'"$CHANGES" "$TAG"
  36. }
  37. push () {
  38. git push --follow-tags
  39. }
  40. update_version_in_source
  41. commit_new_version
  42. add_tag
  43. push
  44. extras/scripts/build-arduino-package.sh
  45. extras/scripts/build-single-header.sh
  46. extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h"