1#!/usr/bin/bash 2 3# Read the date as in the Pacific TZ, with no leading padding 4read year month day <<<$(date --date="TZ=\"US/Pacific\"" +'%-y %-m %-d') 5 6version="$year.$month.$day" 7version_underscore="$year\_$month\_$day" 8 9echo "Setting Flatbuffers Version to: $version" 10 11echo "Updating include/flatbuffers/base.h..." 12sed -i \ 13 -e "s/\(#define FLATBUFFERS_VERSION_MAJOR \).*/\1$year/" \ 14 -e "s/\(#define FLATBUFFERS_VERSION_MINOR \).*/\1$month/" \ 15 -e "s/\(#define FLATBUFFERS_VERSION_REVISION \).*/\1$day/" \ 16 include/flatbuffers/base.h 17 18echo "Updating CMake\Version.cmake..." 19sed -i \ 20 -e "s/\(set(VERSION_MAJOR \).*/\1$year)/" \ 21 -e "s/\(set(VERSION_MINOR \).*/\1$month)/" \ 22 -e "s/\(set(VERSION_PATCH \).*/\1$day)/" \ 23 CMake/Version.cmake 24 25echo "Updating include/flatbuffers/reflection_generated.h..." 26echo "Updating tests/evolution_test/evolution_v1_generated.h..." 27echo "Updating tests/evolution_test/evolution_v1_generated.h..." 28sed -i \ 29 -e "s/\(FLATBUFFERS_VERSION_MAJOR == \)[0-9]*\(.*\)/\1$year\2/" \ 30 -e "s/\(FLATBUFFERS_VERSION_MINOR == \)[0-9]*\(.*\)/\1$month\2/" \ 31 -e "s/\(FLATBUFFERS_VERSION_REVISION == \)[0-9]*\(.*\)/\1$day\2/" \ 32 include/flatbuffers/reflection_generated.h \ 33 tests/evolution_test/evolution_v1_generated.h \ 34 tests/evolution_test/evolution_v2_generated.h 35 36echo "Updating java/pom.xml..." 37xmlstarlet edit --inplace -N s=http://maven.apache.org/POM/4.0.0 \ 38 --update '//s:project/s:version' --value $version \ 39 java/pom.xml 40 41echo "Updating package.json..." 42sed -i \ 43 -e "s/\(\"version\": \).*/\1\"$version\",/" \ 44 package.json 45 46echo "Updating net/FlatBuffers/Google.FlatBuffers.csproj..." 47sed -i \ 48 -e "s/\(<PackageVersion>\).*\(<\/PackageVersion>\)/\1$version\2/" \ 49 net/FlatBuffers/Google.FlatBuffers.csproj 50 51echo "Updating dart/pubspec.yaml..." 52sed -i \ 53 -e "s/\(version: \).*/\1$version/" \ 54 dart/pubspec.yaml 55 56echo "Updating python/flatbuffers/_version.py..." 57sed -i \ 58 -e "s/\(__version__ = u\).*/\1\"$version\"/" \ 59 python/flatbuffers/_version.py 60 61echo "Updating python/setup.py..." 62sed -i \ 63 -e "s/\(version='\).*/\1$version',/" \ 64 python/setup.py 65 66echo "Updating rust/flatbuffers/Cargo.toml..." 67sed -i \ 68 "s/^version = \".*\"$/version = \"$version\"/g" \ 69 rust/flatbuffers/Cargo.toml 70 71echo "Updating FlatBuffers.podspec..." 72sed -i \ 73 -e "s/\(s.version\s*= \).*/\1'$version'/" \ 74 FlatBuffers.podspec 75 76echo "Updating FlatBuffersVersion_X_X_X() version check...." 77grep -rl 'FlatBuffersVersion_' * --exclude=release.sh | xargs -i@ \ 78 sed -i \ 79 -e "s/\(FlatBuffersVersion_\).*()/\1$version_underscore()/g" \ 80 @ 81 82echo "Updating FLATBUFFERS_X_X_X() version check...." 83grep -rl 'FLATBUFFERS_\d*' * --exclude=release.sh | xargs -i@ \ 84 sed -i \ 85 -e "s/\(FLATBUFFERS_\)[0-9]\{2\}.*()/\1$version_underscore()/g" \ 86 @ 87