Repository: logging-log4cxx Updated Branches: refs/heads/release_scripts 3a9fb005f -> af3d97752
Renamed release script files because snake case is used in the files itself and for some other names like "doap_log4cxx.rdf" as well. Project: http://git-wip-us.apache.org/repos/asf/logging-log4cxx/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4cxx/commit/af3d9775 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4cxx/tree/af3d9775 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4cxx/diff/af3d9775 Branch: refs/heads/release_scripts Commit: af3d97752c5ddfbe55efcb18ceed7ab2fe1dc87f Parents: 3a9fb00 Author: Thorsten Schöning <[email protected]> Authored: Thu Aug 17 18:09:12 2017 +0200 Committer: Thorsten Schöning <[email protected]> Committed: Thu Aug 17 18:09:12 2017 +0200 ---------------------------------------------------------------------- releasePerform.sh | 97 -------------------- releasePrepare.sh | 238 ------------------------------------------------ releasePurge.sh | 79 ---------------- release_perform.sh | 97 ++++++++++++++++++++ release_prepare.sh | 238 ++++++++++++++++++++++++++++++++++++++++++++++++ release_purge.sh | 79 ++++++++++++++++ 6 files changed, 414 insertions(+), 414 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4cxx/blob/af3d9775/releasePerform.sh ---------------------------------------------------------------------- diff --git a/releasePerform.sh b/releasePerform.sh deleted file mode 100755 index bbc37cb..0000000 --- a/releasePerform.sh +++ /dev/null @@ -1,97 +0,0 @@ -#! /bin/bash -e -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -## -# Perform a release. -# -# Performing a release involves Maven currently to build and test things and we ran into problems -# with the default dir structure maven assumes. This script works around those and we need to sign -# the release archives anyway, which can be easily automated as well to not need to follow manual -# instructions always. -# -# It's impoirtant to note that this script is expected to be executed in the branch "next_stable", -# most likely prepared by the preparing counterpart. -# - -function main -{ - # log4cxx is able to build using private copies of apr and apr-util, which are expected in some - # special relative dir structure. That doesn't work with the default working dir "perform" uses, - # which is "target/checkout". So we either need to make apr and apr-util available in "target" or - # change the working dir. Making available seems easy using symlinks, but "mvn clean" deletes the - # contents(!) of the linked dirs then. And always copying things around seems a bit unnecessary as - # well, so I'm using a relocation of the folder for now. The downside is that "mvn clean" ignores - # that dir by default... - WD_RELEASE="$( pwd)/../log4cxx-next_stable" - WD_DIST_DEV="$(pwd)/../log4cxx-dist-dev" - - perform_release - prepare_dist_dev - sign_and_copy - publish_for_vote -} - -function perform_release -{ - rm -rf "${WD_RELEASE}" - mvn release:perform "-DworkingDirectory=${WD_RELEASE}" -} - -# Prepare dist/dev to get the release candidate published for a vote. -function prepare_dist_dev -{ - mkdir -p "${WD_DIST_DEV}" - pushd "${WD_DIST_DEV}" > /dev/null - if [ ! -d ".svn" ] - then - svn co "https://dist.apache.org/repos/dist/dev/logging/log4cxx" . - fi - svn up -} - -function sign_and_copy -{ - # Might be a good idea to have another look at the GPG plugin for Maven in the future: - # - # http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ - # http://maven.apache.org/plugins/maven-gpg-plugin/ - pushd "${WD_RELEASE}/target" > /dev/null - for file in *.tar.gz *.zip - do - echo "Processing ${file}:" - - gpg -ab --yes "${file}" > "${file}.asc" - md5sum "${file}" > "${file}.md5" - sha512sum "${file}" > "${file}.sha" - - # No symlinks because those would be treated as is, no hardlinks because it should be safer for - # commits. - cp --force "${file}" "${WD_DIST_DEV}" - cp --force "${file}.asc" "${WD_DIST_DEV}" - cp --force "${file}.md5" "${WD_DIST_DEV}" - cp --force "${file}.sha" "${WD_DIST_DEV}" - done -} - -function publish_for_vote -{ - pushd "${WD_DIST_DEV}" > /dev/null - svn add --force *.* - svn ci -m "Publishing artifacts for new release to vote on." -} - -main http://git-wip-us.apache.org/repos/asf/logging-log4cxx/blob/af3d9775/releasePrepare.sh ---------------------------------------------------------------------- diff --git a/releasePrepare.sh b/releasePrepare.sh deleted file mode 100755 index 962fbec..0000000 --- a/releasePrepare.sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -## -# Prepare a release. -# -# We need to update dates and version numbers at various places during releases and things can go -# wrong, so another RC might need to be released. Am not sure if/how those things are properly -# handled using the Maven release plugin, because that moves versions of the current branch forward -# and doesn't seem to provide a way to say that a new release is just another RC for some former -# release. Additionally, after the current branch has been moved forward, it might have been used to -# merge new changes already. So how to tell Maven to do another release with a former version? -# -# So the current approach of this script is to always create a new branch "next_stable" which acts -# as the base for releases only. One needs to manually merge changes to the code into that branch -# as needed for making a release work, but keep all other changes to "master" etc. outside. We try -# to handle setting release dates, current number of release candidate etc. here automatically as -# much as possible. Some of that info is even merged back into some source branch, e.g. "master", -# because release dates in files like "src/changes/changes.xml" need to be updated with additional -# candidates or later releases. -# -# This script can be invoked with "next_stable" being the current branch already or with some other -# and "next_stable" is checked out automatically. If it's invoked with some other branch, release -# dates, new development version etc. are merged to the branch the script was invoked with. Without -# another branch those changes need to be done/merged manually to wherever they need to be in the -# end, most likely "master". If only "master" should be supported in the future, merging back into -# that might be hard coded, currently it isn't to support arbitrary source branches from which a -# release gets initiated. If "next_stable" is the starting branch, it's assumed to only create -# another release based on a former release, without merging things back to anywhere. -# - -function main -{ - #exit_on_changes - - branch_starting=$( git branch | grep "\*" | cut -d " " -f 2) - branch_starting_is_ns=$(git branch | grep "\* next_stable") - - co_next_stable - set_release_date_if - update_scm_tag_name_format - - exec_mvn - exit_on_started_with_ns - - exit_on_no_new_release_cycle - proc_new_release_cycle -} - -function exit_on_changes -{ - if [[ -n $(git status --short) || -n $(git diff-index HEAD) ]] - then - echo Maven release process requires committed changes! - exit 1 - fi -} - -function co_next_stable -{ - if [ -z "${branch_starting_is_ns}" ] - then - # If we didn't start with "next_stable", don't merge the starting branch, because it contains - # changes regarding new development iteration etc. we don't want to have. People need to merge - # relevant changes manually. - git checkout "next_stable" || git checkout -b "next_stable" - fi -} - -function set_release_date_if -{ - local today=$(date "+%Y-%m-%d") - sed -i -r "1,/date=\".+?\"/ s/date=\".+?\"/date=\"${today}\"/" "src/changes/changes.xml" - git add "src/changes/changes.xml" - - if ! git diff-index --quiet HEAD - then - git commit -m "Set release date to today." - if [ -z "${branch_starting_is_ns}" ] - then - local commit_changes=$(git log --max-count=1 | grep "commit" | cut -d " " -f 2) - git checkout "${branch_starting}" - git merge "${commit_changes}" - git checkout "next_stable" - fi - fi -} - -function update_scm_tag_name_format -{ - local scm_tag_name_format=$(grep "<tagNameFormat>" "pom.xml") - local scm_tag_name_format_needs_one=$(echo "${scm_tag_name_format}" | grep -E -e "-RCx") - local scm_tag_name_format_needs_inc=$(echo "${scm_tag_name_format}" | grep -E -e "-RC[0-9]+" | sed -r "s/.+?-RC([0-9]+).+?/\1/") - - if [ -n "${scm_tag_name_format_needs_one}" ] - then - sed -i -r "s/(<tagNameFormat>.+?-RC)x/\11/" "pom.xml" - fi - if [ -n "${scm_tag_name_format_needs_inc}" ] - then - local inced_nr=$((${scm_tag_name_format_needs_inc} + 1)) - sed -i -r "s/(<tagNameFormat>.+?-RC)[0-9]+/\1${inced_nr}/" "pom.xml" - fi - - git add "pom.xml" - git commit -m "scm.tagNameFormat reconfigured to new RC number." -} - -function get_pom_curr_ver -{ - # \t doesn't seem to work for grep for some reason. - echo "$(grep -E -e "^\s<version>" "pom.xml" | sed -r "s/^\t<.+>(.+)<.+>/\1/")" -} - -function get_mvn_prepare_new_dev_ver -{ - if [ -n "${branch_starting_is_ns}" ] - then - echo "$(get_pom_curr_ver)" - return 0 - fi - - # Maven is able to calculate a useful new version itself, even it warns about not being able to - # parse an empty version. - echo "" -} - -## -# Revert new version in "pom.xml" assigned by Maven. -# -# During release preparation Maven always assigns some new development version to the "pom.xml", -# which is either a new calculated one or one we specified on our own already to be the same like -# before. The first case is needed to get a new version into "release.properties", from where it -# might be merged into a starting branch. In any case, within "next_stable" we want to keep the -# one known version and therefore need to always revert any changes made by maven. So if a specific -# new version is provided, always keep that, while without use the formerly available version of the -# file. The caller most likely already has both values and additionally we are called AFTER Maven -# already changed "pom.xml", so can't get the old value on our own easily anway. -# -# @param[in] Original version from "pom.xml". -# @param[in] Specific version to be used by Maven. -# -function revert_mvn_prepare_new_dev_ver -{ - local pom_orig_ver="${1}" - local new_dev_ver="${2}" - local pom_new_ver="${new_dev_ver:-${pom_orig_ver}}" - - sed -i -r "s/^(\t<version>).+(<)/\1${pom_new_ver}\2/" "pom.xml" -} - -function exec_mvn -{ - local pom_orig_ver="$(get_pom_curr_ver)" - local new_dev_ver="$( get_mvn_prepare_new_dev_ver)" - local prepare_args="-Dresume=false" - - # Avoid a warning about not being able to parse an empty version: - if [ -n "${new_dev_ver}" ] - then - prepare_args="${prepare_args} -DdevelopmentVersion=${new_dev_ver}" - fi - - mvn clean || exit 1 - mvn release:prepare ${prepare_args} || exit 1 - revert_mvn_prepare_new_dev_ver "${pom_orig_ver}" "${new_dev_ver}" - - exit 1 -} - -function exit_on_started_with_ns -{ - if [ -n "${branch_starting_is_ns}" ] - then - exit 0 - fi -} - -function exit_on_no_new_release_cycle -{ - git checkout "${branch_starting}" - local new_release_cycle=$(grep 'date="XXXX-XX-XX"' "src/changes/changes.xml") - - if [ -n "${new_release_cycle}" ] - then - git checkout "next_stable" - exit 0 - fi -} - -function proc_new_release_cycle -{ - git checkout "${branch_starting}" - - local commit_mvn_next_dev_iter=${1} - local new_dev_ver=$( grep -E "^project.dev.log4cxx" "release.properties" | cut -d "=" -f 2) - local new_dev_ver_short=$(grep -E "^project.dev.log4cxx" "release.properties" | cut -d "=" -f 2 | cut -d "-" -f 1) - local new_release=$(cat <<-"END" - <body>\n\ - <release version="VER_NEEDED"\n\ - date="XXXX-XX-XX"\n\ - description="Maintenance release">\n\ - <\/release>\n -END -) - local new_release="${new_release/VER_NEEDED/${new_dev_ver_short}}" - - sed -i -r "s/AC_INIT\(\[log4cxx\], \[.+?\]\)/AC_INIT([log4cxx], [${new_dev_ver_short}])/" "configure.ac" - sed -i -r "s/^(\t<version>).+(<)/\1${new_dev_ver}\2/" "pom.xml" - sed -i -r "s/<body>/${new_release}/" "src/changes/changes.xml" - - git add "configure.ac" - git add "pom.xml" - git add "src/changes/changes.xml" - - if ! git diff-index --quiet HEAD - then - git commit -m "Prepare for next development iteration: ${new_dev_ver_short}" - fi - - git checkout "next_stable" -} - -main http://git-wip-us.apache.org/repos/asf/logging-log4cxx/blob/af3d9775/releasePurge.sh ---------------------------------------------------------------------- diff --git a/releasePurge.sh b/releasePurge.sh deleted file mode 100755 index 1abfcc8..0000000 --- a/releasePurge.sh +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/bash -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -## -# Purge (some) releases during development of release scripts. -# -# This script is mainly used during development of the release scripts itself and simply deletes -# branches and tags created during tests of the release process. Be very careful with execution! -# - -function main -{ - purge_branch_and_tag - revert_pom - revert_changes - commit_reverts -} - -function purge_branch_and_tag -{ - git checkout "release_scripts" - - git branch -D "next_stable" - git push --delete "origin" "next_stable" - - for tag in $(git tag -l | grep "v0.11.0-RC") - do - git tag --delete "${tag}" - git push --delete "origin" "${tag}" - done -} - -function revert_pom -{ - sed -i -r "s/^(\t<version>).+(<)/\10.11.0-SNAPSHOT\2/" "pom.xml" -} - -function revert_changes -{ - if [ -n "$(grep "version=\"0.11.1\"" "src/changes/changes.xml")" ] - then - # Remove not needed "release" node. - sed -i -r "1,/.+<release.+/ s/.+<release.+//" "src/changes/changes.xml" - sed -i -r "1,/.+date=.+/ s/.+date=.+//" "src/changes/changes.xml" - sed -i -r "1,/.+description=.+/ s/.+description=.+//" "src/changes/changes.xml" - sed -i -r "1,/.+<\/release.+/ s/.+<\/release.+//" "src/changes/changes.xml" - - # Don't know how to remove the left newlines easier... - local changes=$(cat "src/changes/changes.xml") - echo "${changes/$'\n\n\n\n\n'/}" > "src/changes/changes.xml" - fi - - # Last release date needs to be "unknown": - sed -i -r "1,/.+date=.+/ s/date=\".+\"/date=\"XXXX-XX-XX\"/" "src/changes/changes.xml" -} - -function commit_reverts -{ - git add "pom.xml" - git add "src/changes/changes.xml" - - git commit -m "No 0.11.1 yet." -} - -main http://git-wip-us.apache.org/repos/asf/logging-log4cxx/blob/af3d9775/release_perform.sh ---------------------------------------------------------------------- diff --git a/release_perform.sh b/release_perform.sh new file mode 100755 index 0000000..bbc37cb --- /dev/null +++ b/release_perform.sh @@ -0,0 +1,97 @@ +#! /bin/bash -e +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +## +# Perform a release. +# +# Performing a release involves Maven currently to build and test things and we ran into problems +# with the default dir structure maven assumes. This script works around those and we need to sign +# the release archives anyway, which can be easily automated as well to not need to follow manual +# instructions always. +# +# It's impoirtant to note that this script is expected to be executed in the branch "next_stable", +# most likely prepared by the preparing counterpart. +# + +function main +{ + # log4cxx is able to build using private copies of apr and apr-util, which are expected in some + # special relative dir structure. That doesn't work with the default working dir "perform" uses, + # which is "target/checkout". So we either need to make apr and apr-util available in "target" or + # change the working dir. Making available seems easy using symlinks, but "mvn clean" deletes the + # contents(!) of the linked dirs then. And always copying things around seems a bit unnecessary as + # well, so I'm using a relocation of the folder for now. The downside is that "mvn clean" ignores + # that dir by default... + WD_RELEASE="$( pwd)/../log4cxx-next_stable" + WD_DIST_DEV="$(pwd)/../log4cxx-dist-dev" + + perform_release + prepare_dist_dev + sign_and_copy + publish_for_vote +} + +function perform_release +{ + rm -rf "${WD_RELEASE}" + mvn release:perform "-DworkingDirectory=${WD_RELEASE}" +} + +# Prepare dist/dev to get the release candidate published for a vote. +function prepare_dist_dev +{ + mkdir -p "${WD_DIST_DEV}" + pushd "${WD_DIST_DEV}" > /dev/null + if [ ! -d ".svn" ] + then + svn co "https://dist.apache.org/repos/dist/dev/logging/log4cxx" . + fi + svn up +} + +function sign_and_copy +{ + # Might be a good idea to have another look at the GPG plugin for Maven in the future: + # + # http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/ + # http://maven.apache.org/plugins/maven-gpg-plugin/ + pushd "${WD_RELEASE}/target" > /dev/null + for file in *.tar.gz *.zip + do + echo "Processing ${file}:" + + gpg -ab --yes "${file}" > "${file}.asc" + md5sum "${file}" > "${file}.md5" + sha512sum "${file}" > "${file}.sha" + + # No symlinks because those would be treated as is, no hardlinks because it should be safer for + # commits. + cp --force "${file}" "${WD_DIST_DEV}" + cp --force "${file}.asc" "${WD_DIST_DEV}" + cp --force "${file}.md5" "${WD_DIST_DEV}" + cp --force "${file}.sha" "${WD_DIST_DEV}" + done +} + +function publish_for_vote +{ + pushd "${WD_DIST_DEV}" > /dev/null + svn add --force *.* + svn ci -m "Publishing artifacts for new release to vote on." +} + +main http://git-wip-us.apache.org/repos/asf/logging-log4cxx/blob/af3d9775/release_prepare.sh ---------------------------------------------------------------------- diff --git a/release_prepare.sh b/release_prepare.sh new file mode 100755 index 0000000..962fbec --- /dev/null +++ b/release_prepare.sh @@ -0,0 +1,238 @@ +#! /bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +## +# Prepare a release. +# +# We need to update dates and version numbers at various places during releases and things can go +# wrong, so another RC might need to be released. Am not sure if/how those things are properly +# handled using the Maven release plugin, because that moves versions of the current branch forward +# and doesn't seem to provide a way to say that a new release is just another RC for some former +# release. Additionally, after the current branch has been moved forward, it might have been used to +# merge new changes already. So how to tell Maven to do another release with a former version? +# +# So the current approach of this script is to always create a new branch "next_stable" which acts +# as the base for releases only. One needs to manually merge changes to the code into that branch +# as needed for making a release work, but keep all other changes to "master" etc. outside. We try +# to handle setting release dates, current number of release candidate etc. here automatically as +# much as possible. Some of that info is even merged back into some source branch, e.g. "master", +# because release dates in files like "src/changes/changes.xml" need to be updated with additional +# candidates or later releases. +# +# This script can be invoked with "next_stable" being the current branch already or with some other +# and "next_stable" is checked out automatically. If it's invoked with some other branch, release +# dates, new development version etc. are merged to the branch the script was invoked with. Without +# another branch those changes need to be done/merged manually to wherever they need to be in the +# end, most likely "master". If only "master" should be supported in the future, merging back into +# that might be hard coded, currently it isn't to support arbitrary source branches from which a +# release gets initiated. If "next_stable" is the starting branch, it's assumed to only create +# another release based on a former release, without merging things back to anywhere. +# + +function main +{ + #exit_on_changes + + branch_starting=$( git branch | grep "\*" | cut -d " " -f 2) + branch_starting_is_ns=$(git branch | grep "\* next_stable") + + co_next_stable + set_release_date_if + update_scm_tag_name_format + + exec_mvn + exit_on_started_with_ns + + exit_on_no_new_release_cycle + proc_new_release_cycle +} + +function exit_on_changes +{ + if [[ -n $(git status --short) || -n $(git diff-index HEAD) ]] + then + echo Maven release process requires committed changes! + exit 1 + fi +} + +function co_next_stable +{ + if [ -z "${branch_starting_is_ns}" ] + then + # If we didn't start with "next_stable", don't merge the starting branch, because it contains + # changes regarding new development iteration etc. we don't want to have. People need to merge + # relevant changes manually. + git checkout "next_stable" || git checkout -b "next_stable" + fi +} + +function set_release_date_if +{ + local today=$(date "+%Y-%m-%d") + sed -i -r "1,/date=\".+?\"/ s/date=\".+?\"/date=\"${today}\"/" "src/changes/changes.xml" + git add "src/changes/changes.xml" + + if ! git diff-index --quiet HEAD + then + git commit -m "Set release date to today." + if [ -z "${branch_starting_is_ns}" ] + then + local commit_changes=$(git log --max-count=1 | grep "commit" | cut -d " " -f 2) + git checkout "${branch_starting}" + git merge "${commit_changes}" + git checkout "next_stable" + fi + fi +} + +function update_scm_tag_name_format +{ + local scm_tag_name_format=$(grep "<tagNameFormat>" "pom.xml") + local scm_tag_name_format_needs_one=$(echo "${scm_tag_name_format}" | grep -E -e "-RCx") + local scm_tag_name_format_needs_inc=$(echo "${scm_tag_name_format}" | grep -E -e "-RC[0-9]+" | sed -r "s/.+?-RC([0-9]+).+?/\1/") + + if [ -n "${scm_tag_name_format_needs_one}" ] + then + sed -i -r "s/(<tagNameFormat>.+?-RC)x/\11/" "pom.xml" + fi + if [ -n "${scm_tag_name_format_needs_inc}" ] + then + local inced_nr=$((${scm_tag_name_format_needs_inc} + 1)) + sed -i -r "s/(<tagNameFormat>.+?-RC)[0-9]+/\1${inced_nr}/" "pom.xml" + fi + + git add "pom.xml" + git commit -m "scm.tagNameFormat reconfigured to new RC number." +} + +function get_pom_curr_ver +{ + # \t doesn't seem to work for grep for some reason. + echo "$(grep -E -e "^\s<version>" "pom.xml" | sed -r "s/^\t<.+>(.+)<.+>/\1/")" +} + +function get_mvn_prepare_new_dev_ver +{ + if [ -n "${branch_starting_is_ns}" ] + then + echo "$(get_pom_curr_ver)" + return 0 + fi + + # Maven is able to calculate a useful new version itself, even it warns about not being able to + # parse an empty version. + echo "" +} + +## +# Revert new version in "pom.xml" assigned by Maven. +# +# During release preparation Maven always assigns some new development version to the "pom.xml", +# which is either a new calculated one or one we specified on our own already to be the same like +# before. The first case is needed to get a new version into "release.properties", from where it +# might be merged into a starting branch. In any case, within "next_stable" we want to keep the +# one known version and therefore need to always revert any changes made by maven. So if a specific +# new version is provided, always keep that, while without use the formerly available version of the +# file. The caller most likely already has both values and additionally we are called AFTER Maven +# already changed "pom.xml", so can't get the old value on our own easily anway. +# +# @param[in] Original version from "pom.xml". +# @param[in] Specific version to be used by Maven. +# +function revert_mvn_prepare_new_dev_ver +{ + local pom_orig_ver="${1}" + local new_dev_ver="${2}" + local pom_new_ver="${new_dev_ver:-${pom_orig_ver}}" + + sed -i -r "s/^(\t<version>).+(<)/\1${pom_new_ver}\2/" "pom.xml" +} + +function exec_mvn +{ + local pom_orig_ver="$(get_pom_curr_ver)" + local new_dev_ver="$( get_mvn_prepare_new_dev_ver)" + local prepare_args="-Dresume=false" + + # Avoid a warning about not being able to parse an empty version: + if [ -n "${new_dev_ver}" ] + then + prepare_args="${prepare_args} -DdevelopmentVersion=${new_dev_ver}" + fi + + mvn clean || exit 1 + mvn release:prepare ${prepare_args} || exit 1 + revert_mvn_prepare_new_dev_ver "${pom_orig_ver}" "${new_dev_ver}" + + exit 1 +} + +function exit_on_started_with_ns +{ + if [ -n "${branch_starting_is_ns}" ] + then + exit 0 + fi +} + +function exit_on_no_new_release_cycle +{ + git checkout "${branch_starting}" + local new_release_cycle=$(grep 'date="XXXX-XX-XX"' "src/changes/changes.xml") + + if [ -n "${new_release_cycle}" ] + then + git checkout "next_stable" + exit 0 + fi +} + +function proc_new_release_cycle +{ + git checkout "${branch_starting}" + + local commit_mvn_next_dev_iter=${1} + local new_dev_ver=$( grep -E "^project.dev.log4cxx" "release.properties" | cut -d "=" -f 2) + local new_dev_ver_short=$(grep -E "^project.dev.log4cxx" "release.properties" | cut -d "=" -f 2 | cut -d "-" -f 1) + local new_release=$(cat <<-"END" + <body>\n\ + <release version="VER_NEEDED"\n\ + date="XXXX-XX-XX"\n\ + description="Maintenance release">\n\ + <\/release>\n +END +) + local new_release="${new_release/VER_NEEDED/${new_dev_ver_short}}" + + sed -i -r "s/AC_INIT\(\[log4cxx\], \[.+?\]\)/AC_INIT([log4cxx], [${new_dev_ver_short}])/" "configure.ac" + sed -i -r "s/^(\t<version>).+(<)/\1${new_dev_ver}\2/" "pom.xml" + sed -i -r "s/<body>/${new_release}/" "src/changes/changes.xml" + + git add "configure.ac" + git add "pom.xml" + git add "src/changes/changes.xml" + + if ! git diff-index --quiet HEAD + then + git commit -m "Prepare for next development iteration: ${new_dev_ver_short}" + fi + + git checkout "next_stable" +} + +main http://git-wip-us.apache.org/repos/asf/logging-log4cxx/blob/af3d9775/release_purge.sh ---------------------------------------------------------------------- diff --git a/release_purge.sh b/release_purge.sh new file mode 100755 index 0000000..1abfcc8 --- /dev/null +++ b/release_purge.sh @@ -0,0 +1,79 @@ +#! /bin/bash +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +## +# Purge (some) releases during development of release scripts. +# +# This script is mainly used during development of the release scripts itself and simply deletes +# branches and tags created during tests of the release process. Be very careful with execution! +# + +function main +{ + purge_branch_and_tag + revert_pom + revert_changes + commit_reverts +} + +function purge_branch_and_tag +{ + git checkout "release_scripts" + + git branch -D "next_stable" + git push --delete "origin" "next_stable" + + for tag in $(git tag -l | grep "v0.11.0-RC") + do + git tag --delete "${tag}" + git push --delete "origin" "${tag}" + done +} + +function revert_pom +{ + sed -i -r "s/^(\t<version>).+(<)/\10.11.0-SNAPSHOT\2/" "pom.xml" +} + +function revert_changes +{ + if [ -n "$(grep "version=\"0.11.1\"" "src/changes/changes.xml")" ] + then + # Remove not needed "release" node. + sed -i -r "1,/.+<release.+/ s/.+<release.+//" "src/changes/changes.xml" + sed -i -r "1,/.+date=.+/ s/.+date=.+//" "src/changes/changes.xml" + sed -i -r "1,/.+description=.+/ s/.+description=.+//" "src/changes/changes.xml" + sed -i -r "1,/.+<\/release.+/ s/.+<\/release.+//" "src/changes/changes.xml" + + # Don't know how to remove the left newlines easier... + local changes=$(cat "src/changes/changes.xml") + echo "${changes/$'\n\n\n\n\n'/}" > "src/changes/changes.xml" + fi + + # Last release date needs to be "unknown": + sed -i -r "1,/.+date=.+/ s/date=\".+\"/date=\"XXXX-XX-XX\"/" "src/changes/changes.xml" +} + +function commit_reverts +{ + git add "pom.xml" + git add "src/changes/changes.xml" + + git commit -m "No 0.11.1 yet." +} + +main
