Last active
August 29, 2015 14:00
-
-
Save imesh/11204904 to your computer and use it in GitHub Desktop.
Deploy maven artifacts to Apache snapshots and staging repositories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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. | |
| # ----------------------------------------------------------------- | |
| # Deploy maven artifacts to Apache snapshots and staging repositories. | |
| # ----------------------------------------------------------------- | |
| set -e | |
| log="/tmp/apache-stratos-4.1.0-rc1-release.log" | |
| stratos_path="/mnt/source/stratos/" | |
| release_version="4.1.0" | |
| development_version="4.2.0-SNAPSHOT" | |
| release_tag="4.1.0-rc1" | |
| retry_count=0 | |
| retry_limit=5 | |
| reset_all_steps() { | |
| checkout=false | |
| build=false | |
| rat=false | |
| deploy=false | |
| prepare_release=false | |
| perform_release=false | |
| } | |
| validate() { | |
| if grep -q "BUILD FAILURE" "$log"; then | |
| echo "[STRATOS-RELEASE] BUILD FAILED! Please check the log" | tee -a $log | |
| if [ $retry_count -le $retry_limit ]; then | |
| echo `date` " [STRATOS-RELEASE] Retrying build... [retry-count] $retry_count" | tee -a $log | |
| if [ "$deploy" = true ] && [ "$prepare_release" = false ] ; then | |
| echo `date` " [STRATOS-RELEASE] Failed at prepare-release, starting over..." | tee -a $log | |
| reset_all_steps | |
| fi | |
| execute | |
| else | |
| exit | |
| fi | |
| fi | |
| } | |
| checkout_branch() { | |
| echo `date` " [STRATOS-RELEASE] Checking out ${release_version} branch..." | tee -a $log | |
| pushd /mnt/source | |
| rm -rf stratos/ | |
| git clone https://git-wip-us.apache.org/repos/asf/stratos.git | |
| chown -R ubuntu:ubuntu stratos | |
| popd | |
| pushd /mnt/source/stratos | |
| git checkout ${release_version} | |
| popd | |
| } | |
| execute() { | |
| if [ -f $log ]; then | |
| mv $log $log.$retry_count | |
| fi; | |
| retry_count=$((retry_count + 1)); | |
| if [ "$checkout" = false ] ; then | |
| checkout_branch | |
| checkout=true | |
| fi | |
| if [ "$build" = false ] ; then | |
| echo "[STRATOS-RELEASE] Building..." | tee -a $log | |
| pushd ${stratos_path} | |
| mvn clean install | tee -a $log | |
| popd | |
| validate | |
| build=true | |
| fi | |
| if [ "$rat" = false ] ; then | |
| echo "Running RAT..." | tee -a $log | |
| pushd ${stratos_path} | |
| mvn -P pedantic verify | tee -a $log | |
| popd | tee -a $log | |
| validate | tee -a $log | |
| rat=true | |
| fi | |
| if [ "$deploy" = false ] ; then | |
| echo `date` " [STRATOS-RELEASE] Deploying artifacts..." | tee -a $log | |
| pushd ${stratos_path} | |
| mvn clean deploy | tee -a $log | |
| popd | |
| validate | |
| deploy=true | |
| fi | |
| if [ "$prepare_release" = false ] ; then | |
| echo `date` " [STRATOS-RELEASE] Preparing release..." | tee -a $log | |
| pushd ${stratos_path} | |
| mvn release:clean release:prepare -DreleaseVersion=${release_version} -Dtag=${release_tag} -DdevelopmentVersion=${development_version} -DpushChanges=false | tee -a $log | |
| popd | |
| validate | |
| prepare_release=true | |
| fi | |
| if [ "$perform_release" = false ] ; then | |
| echo `date` " [STRATOS-RELEASE] Performing release..." | tee -a $log | |
| pushd ${stratos_path} | |
| mvn clean release:perform -DconnectionUrl=scm:git:file://`pwd`/.git -Dtag=${release_tag} -Darguments="-DskipTests" | tee -a $log | |
| popd | |
| validate | |
| perform_release=true | |
| fi | |
| echo `date` " [STRATOS-RELEASE] Release successfull!" | tee -a $log | |
| } | |
| reset_all_steps | |
| execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment