From a27d8c7ff24c282b2a7bf943dfec039d7ef02f72 Mon Sep 17 00:00:00 2001 From: Vadym Matsishevskyi Date: Mon, 17 Apr 2017 12:52:48 -0700 Subject: [PATCH] Update README.md version update script (#1929) Merge readmes update script in update versions script, as they are related, depend on same versioning logic, during the release process always performed sequentially. --- utilities/stage_release.sh | 5 ----- utilities/update_docs_version.sh | 33 ------------------------------ utilities/update_readme_version.sh | 31 ---------------------------- utilities/update_versions.sh | 29 +++++++++++++++++++++++--- 4 files changed, 26 insertions(+), 72 deletions(-) delete mode 100755 utilities/update_docs_version.sh delete mode 100755 utilities/update_readme_version.sh diff --git a/utilities/stage_release.sh b/utilities/stage_release.sh index c5a380070c69..2a5193fa0de8 100755 --- a/utilities/stage_release.sh +++ b/utilities/stage_release.sh @@ -13,11 +13,6 @@ fi ./utilities/deploy.sh "$SITE_VERSION" if [ "${SITE_VERSION##*-}" != "SNAPSHOT" ]; then - # Update the versions on the docs - ./utilities/update_readme_version.sh - - git commit --quiet -m "Updating version in README files. [ci skip]" - # Create website ./utilities/create_site.sh "$SITE_VERSION" diff --git a/utilities/update_docs_version.sh b/utilities/update_docs_version.sh deleted file mode 100755 index 2721e20166e7..000000000000 --- a/utilities/update_docs_version.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# This script updates the READMEs with the latest non-SNAPSHOT version number. -# Example: Suppose that before running this script, the pom.xml reads 7.8.9. This script will replace -# all occurrences of #.#.# with 7.8.9 in the README files. - -# Get the current maven project version. -RELEASED_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)') - -if [ "${RELEASED_VERSION##*-}" != "SNAPSHOT" ]; then - echo "Changing version to $RELEASED_VERSION in README files" - # Get list of directories for which README.md must be updated - module_folders=($(find . -maxdepth 2 -type d | sed -E -n "/^\.\/(google-cloud-contrib\/)?google-cloud(-[a-z]+)+$/p") . ./google-cloud) - readmes="" - for item in ${module_folders[*]} - do - if [ -f ${item}/README.md ]; then - sed -ri "s/[0-9]+\.[0-9]+\.[0-9]+<\/version>/${RELEASED_VERSION}<\/version>/g" ${item}/README.md - sed -ri "s/:[0-9]+\.[0-9]+\.[0-9]+'/:${RELEASED_VERSION}'/g" ${item}/README.md - sed -ri "s/\"[0-9]+\.[0-9]+\.[0-9]+\"/\"${RELEASED_VERSION}\"/g" ${item}/README.md - readmes="$readmes ${item}/README.md" - fi - done - NEW_VERSION=${RELEASED_VERSION%.*}.$((${RELEASED_VERSION##*.}+1))-SNAPSHOT - echo "Changing version to $NEW_VERSION in google-cloud-nio-example README" - sed -ri "s/google-cloud-nio-[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT/google-cloud-nio-$NEW_VERSION/g" google-cloud-contrib/google-cloud-nio-examples/README.md - sed -ri "s/google-cloud-nio-examples-[0-9]+\.[0-9]+\.[0-9]+-SNAPSHOT/google-cloud-nio-examples-$NEW_VERSION/g" google-cloud-contrib/google-cloud-nio-examples/README.md - git add $readmes - git config --global user.name "travis-ci" - git config --global user.email "travis@travis-ci.org" - git commit -m "Updating version in README files. [ci skip]" - git push --quiet "https://${CI_DEPLOY_USERNAME}:${CI_DEPLOY_PASSWORD}@github.com/GoogleCloudPlatform/google-cloud-java.git" HEAD:master > /dev/null 2>&1 -fi diff --git a/utilities/update_readme_version.sh b/utilities/update_readme_version.sh deleted file mode 100755 index b588cb6e82b1..000000000000 --- a/utilities/update_readme_version.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# This script updates the READMEs with the latest non-SNAPSHOT version number. -# Example: Suppose that before running this script, the pom.xml reads 7.8.9. This script will replace -# all occurrences of #.#.# with 7.8.9 in the README files. - -set -e - -# Get the current maven project version. -RELEASED_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '(^\[|\w+:)' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') - -if [ "${RELEASED_VERSION##*-}" != "SNAPSHOT" ]; then - echo "Changing version to $RELEASED_VERSION in README files" - # Get list of directories for which README.md must be updated - module_folders=($(find . -maxdepth 2 -type d | sed -E -n "/^\.\/(google-cloud-contrib\/)?google-cloud(-[a-z]+)+$/p") . ./google-cloud) - readmes="" - for item in ${module_folders[*]} - do - if [ -f ${item}/README.md ]; then - sed -ri "s/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?<\/version>/${RELEASED_VERSION}\1<\/version>/g" ${item}/README.md - sed -ri "s/:[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?'/:${RELEASED_VERSION}\1'/g" ${item}/README.md - sed -ri "s/\"[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?\"/\"${RELEASED_VERSION}\1\"/g" ${item}/README.md - readmes="$readmes ${item}/README.md" - fi - done - NEW_VERSION=${RELEASED_VERSION%.*}.$((${RELEASED_VERSION##*.}+1))-alpha-SNAPSHOT - echo "Changing version to $NEW_VERSION in google-cloud-nio-example README" - sed -ri "s/google-cloud-nio-[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?-SNAPSHOT/google-cloud-nio-$NEW_VERSION/g" google-cloud-contrib/google-cloud-nio-examples/README.md - sed -ri "s/google-cloud-nio-examples-[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?-SNAPSHOT/google-cloud-nio-examples-$NEW_VERSION/g" google-cloud-contrib/google-cloud-nio-examples/README.md - git add $readmes -fi diff --git a/utilities/update_versions.sh b/utilities/update_versions.sh index 6f7ca385cf52..460ba21b6317 100755 --- a/utilities/update_versions.sh +++ b/utilities/update_versions.sh @@ -2,7 +2,7 @@ # Requires bash version >= 4. -# This script updates pom.xml and other relevant files to the next version number. +# This script updates pom.xml, README.md and other relevant files to the next version number. # This script is meant to be run manually (not by Travis) # Arguments (optional): @@ -148,15 +148,38 @@ for item in ${modules[*]}; do fi echo -e "Updating module ${BOLD}${module}${NC} in folder ${folder} from version ${RED}${old_version}${NC} to ${GREEN}${new_version}${NC}" + module_suffix=${module##*-} # Where the actual version changing happens (the only mutative operations in the script). - module_suffix=${module##*-} + + # 1) Update version properties (used to define dependencies between google-cloud modules). + echo -e " Updating ${module_suffix}.version property in root pom.xml" sed -ri "s/(<${module_suffix}.version>\s*)((\w|-|\.)+)(\s*<\/${module_suffix}.version>)/\1${new_version}\4/" pom.xml + + # 2) Update version of the module. If the module is a parent of other modules + # (like the root module or the google-cloud-contrib), then the parent secion of its child modules + # will be updated too. + echo -e " Updating version in ${folder}\pom.xml and the parent version in the corresponding children modules if exist" mvn -q versions:set -DartifactId=${module} -DnewVersion=${new_version} -DprocessPlugins=false -DgenerateBackupPoms=false + # 3) Update Google App Engine application dockerfile, if it exists. if [ -w ${folder}/src/main/docker/Dockerfile ]; then old_version="${module_version_map[${module}]}" - echo "Updating ${folder}/src/main/docker/Dockerfile" + echo -e " Updating ${folder}/src/main/docker/Dockerfile" sed -ri "s/${old_version}/${new_version}/" ${folder}/src/main/docker/Dockerfile fi + + # 4) Update README.md + if [ "${new_snapshot}" == "" ] && [ -f ${folder}/README.md ]; then + echo -e " Updating ${folder}/README.md" + if [ "${module}" != "google-cloud-nio-examples" ]; then + sed -ri "s/[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?<\/version>/${new_version}<\/version>/g" ${folder}/README.md + sed -ri "s/:[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?'/:${new_version}'/g" ${folder}/README.md + sed -ri "s/\"[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?\"/\"${new_version}\"/g" ${folder}/README.md + else + examples_version=${new_base_version%.*}.$((${new_base_version##*.}+1))-alpha-SNAPSHOT + sed -ri "s/google-cloud-nio-[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?-SNAPSHOT/google-cloud-nio-${examples_version}/g" ${folder}/README.md + sed -ri "s/google-cloud-nio-examples-[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+)?-SNAPSHOT/google-cloud-nio-examples-${examples_version}/g" ${folder}/README.md + fi + fi done