2018-08-31 16:57:14 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-08-31 17:04:15 +02:00
|
|
|
set -eu
|
2018-08-31 16:57:14 +02:00
|
|
|
|
2022-01-08 16:40:21 +01:00
|
|
|
which awk sed jq 7z curl perl >/dev/null
|
|
|
|
|
2019-09-03 15:11:05 +02:00
|
|
|
cd "$(dirname "$0")/../.."
|
2018-08-31 16:57:14 +02:00
|
|
|
|
2022-01-08 16:21:09 +01:00
|
|
|
if ! git diff --quiet --exit-code; then
|
|
|
|
echo "Repository contains uncommitted changes"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2018-08-31 16:57:14 +02:00
|
|
|
VERSION="$1"
|
|
|
|
DATE=$(date +%F)
|
|
|
|
TAG="v$VERSION"
|
2022-01-05 12:08:18 +01:00
|
|
|
VERSION_REGEX='[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9]+)?'
|
2018-08-31 16:57:14 +02:00
|
|
|
|
|
|
|
update_version_in_source () {
|
|
|
|
IFS=".-" read MAJOR MINOR REVISION EXTRA < <(echo "$VERSION")
|
|
|
|
UNDERLINE=$(printf -- '-%.0s' $(seq 1 ${#TAG}))
|
|
|
|
|
2022-01-05 12:08:18 +01:00
|
|
|
sed -i~ -bE "1,20{s/$VERSION_REGEX/$VERSION/g}" README.md
|
2020-05-15 09:26:06 +02:00
|
|
|
rm README.md~
|
2019-01-30 15:23:55 +01:00
|
|
|
|
2018-08-31 16:57:14 +02:00
|
|
|
sed -i~ -bE "4s/HEAD/$TAG ($DATE)/; 5s/-+/$UNDERLINE/" CHANGELOG.md
|
2020-05-15 09:26:06 +02:00
|
|
|
rm CHANGELOG.md~
|
2019-03-04 12:20:30 +01:00
|
|
|
|
2020-04-09 21:28:48 +02:00
|
|
|
sed -i~ -bE "s/(project\\s*\\(ArduinoJson\\s+VERSION\\s+).*?\\)/\\1$MAJOR.$MINOR.$REVISION)/" CMakeLists.txt
|
2020-05-15 09:26:06 +02:00
|
|
|
rm CMakeLists.txt~
|
2020-04-09 21:28:48 +02:00
|
|
|
|
2018-08-31 16:57:14 +02:00
|
|
|
sed -i~ -bE "s/\"version\":.*$/\"version\": \"$VERSION\",/" library.json
|
2020-05-15 09:26:06 +02:00
|
|
|
rm library.json~
|
2018-08-31 16:57:14 +02:00
|
|
|
|
|
|
|
sed -i~ -bE "s/version=.*$/version=$VERSION/" library.properties
|
2020-05-15 09:26:06 +02:00
|
|
|
rm library.properties~
|
2018-08-31 16:57:14 +02:00
|
|
|
|
2019-03-04 12:20:30 +01:00
|
|
|
sed -i~ -bE "s/version: .*$/version: $VERSION.{build}/" appveyor.yml
|
2020-05-15 09:26:06 +02:00
|
|
|
rm appveyor.yml~
|
2019-03-04 12:20:30 +01:00
|
|
|
|
2018-08-31 16:57:14 +02:00
|
|
|
sed -i~ -bE \
|
|
|
|
-e "s/ARDUINOJSON_VERSION .*$/ARDUINOJSON_VERSION \"$VERSION\"/" \
|
|
|
|
-e "s/ARDUINOJSON_VERSION_MAJOR .*$/ARDUINOJSON_VERSION_MAJOR $MAJOR/" \
|
|
|
|
-e "s/ARDUINOJSON_VERSION_MINOR .*$/ARDUINOJSON_VERSION_MINOR $MINOR/" \
|
|
|
|
-e "s/ARDUINOJSON_VERSION_REVISION .*$/ARDUINOJSON_VERSION_REVISION $REVISION/" \
|
|
|
|
src/ArduinoJson/version.hpp
|
|
|
|
rm src/ArduinoJson/version.hpp*~
|
|
|
|
}
|
|
|
|
|
|
|
|
commit_new_version () {
|
2020-08-01 15:34:27 +02:00
|
|
|
git add src/ArduinoJson/version.hpp README.md CHANGELOG.md library.json library.properties appveyor.yml CMakeLists.txt
|
2018-08-31 16:57:14 +02:00
|
|
|
git commit -m "Set version to $VERSION"
|
|
|
|
}
|
|
|
|
|
|
|
|
add_tag () {
|
|
|
|
CHANGES=$(awk '/\* /{ FOUND=1; print; next } { if (FOUND) exit}' CHANGELOG.md)
|
2018-08-31 17:04:15 +02:00
|
|
|
git tag -m "ArduinoJson $VERSION"$'\n'"$CHANGES" "$TAG"
|
|
|
|
}
|
|
|
|
|
|
|
|
push () {
|
|
|
|
git push --follow-tags
|
2018-08-31 16:57:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
update_version_in_source
|
|
|
|
commit_new_version
|
|
|
|
add_tag
|
2018-08-31 17:04:15 +02:00
|
|
|
push
|
2018-11-14 18:02:01 +01:00
|
|
|
|
2021-07-16 09:35:32 +02:00
|
|
|
extras/scripts/build-arduino-package.sh . "../ArduinoJson-$TAG.zip"
|
2021-07-03 16:08:36 +02:00
|
|
|
extras/scripts/build-single-header.sh "src/ArduinoJson.h" "../ArduinoJson-$TAG.h"
|
|
|
|
extras/scripts/build-single-header.sh "src/ArduinoJson.hpp" "../ArduinoJson-$TAG.hpp"
|
2022-01-14 09:22:55 +01:00
|
|
|
extras/scripts/wandbox/publish.sh "../ArduinoJson-$TAG.h" > "../ArduinoJson-$TAG-wandbox.txt" || echo "Wandbox failed!"
|
2021-07-19 10:19:04 +02:00
|
|
|
extras/scripts/get-release-page.sh "$VERSION" "CHANGELOG.md" "../ArduinoJson-$TAG-wandbox.txt" > "../ArduinoJson-$TAG.md"
|
2021-07-19 09:58:01 +02:00
|
|
|
|
|
|
|
echo "You can now copy ../ArduinoJson-$TAG.md into arduinojson.org/collections/_versions/$VERSION.md"
|