https://github.com/btrplace/scheduler
Raw File
Tip revision: 878b6368b0c2835ad6047c4d8363cf80fb6bb291 authored by Jenkins on 07 May 2013, 12:04:16 UTC
[maven-release-plugin] prepare release btrplace-solver-0.29
Tip revision: 878b636
release.sh
#!/bin/sh


if [ $# != 1 ]; then
    echo "Usage: $0 request|perform"
    exit 1
fi


function getVersionToRelease {
    CURRENT_VERSION=`mvn ${MVN_ARGS} org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v "\[INFO\]"`
    echo ${CURRENT_VERSION%%-SNAPSHOT}
}

function getVersion {
    mvn ${MVN_ARGS} org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v "\[INFO\]"    
}
function getBranch {
    git symbolic-ref --short HEAD
}

case $1 in
request)        
    VERSION=$(getVersionToRelease)
    RELEASE_BRANCH="release/$VERSION"        
    git checkout -b ${RELEASE_BRANCH} || exit 1

    echo "-- Prepare the code for release ${VERSION} in branch ${RELEASE_BRANCH} --"
    echo $VERSION > .version
    git add .version    
    ./bump_release.sh code $VERSION || exit 1
    
    git commit -m "Prepare the code for release ${VERSION}" -a
    git push origin ${RELEASE_BRANCH} || exit 1
    git checkout develop
    echo "Branch $RELEASE_BRANCH is ready for the releasing process"
    ;;
perform)    
    if [ $(hostname) != "btrp" ]; then
            echo "This script must be executed on btrp.inria.fr"
            exit 1
    fi    
    if [ ! -f .version ]; then
        echo "Missing .version file"
        exit 1
    fi
    VERSION=$(cat .version)
        
    echo "-- Prepare the release --"
    mvn -B release:prepare || exit 1

    echo "-- Perform the release --"
    mvn release:perform || exit 1
    rm .version #To prevent for an infinite loop
    
    DEV_HEAD=$(git rev-parse HEAD)
    RELEASE_BRANCH="release/${VERSION}"
    # The current tree looks like:
    # * HEAD -> next dev version, it is a detached head due to jenkins git plugin
    # * (tag ...) -> the tag made by maven release:prepare on the relased version == ${DEV_HEAD}~1
    # * ($RELEASE_BRANCH) -> the pointer on the released branch that was set by the client with ./release.sh request
    
    # merge the version changes back into develop so that folks are working against the new release
    git checkout develop
    NEW_VERSION=$(getVersion)
    echo "-- Integrate the next version ${NEW_VERSION} into the develop branch --"
    git merge --no-ff -m "integrate the development version ${NEW_VERSION} generated by maven" ${DEV_HEAD} || exit 1        
    ./bump_release.sh code ${NEW_VERSION}
    git commit -m "code prepared for development version ${NEW_VERSION}" -a

    
    echo "-- Integrate release ${VERSION} into the master branch --"
    git checkout ${RELEASE_BRANCH}
    git merge -s ours master -m "merge master into the release"
    git checkout master    
    git merge --no-ff ${DEV_HEAD}~1 -m "integrate release ${VERSION} to master"

    echo "-- Generate the javadoc for release ${VERSION} --"
    mvn javadoc:aggregate > /dev/null
    mvn javadoc:aggregate-jar > /dev/null
    APIDOC_ROOT="/usr/share/nginx/html/apidocs/releases/btrplace/solver/"
    mkdir -p $APIDOC_ROOT > /dev/null
    rm -rf ${APIDOC_ROOT}/${VERSION}
    mv target/site/apidocs ${APIDOC_ROOT}/${VERSION}
    mv target/solver-${VERSION}-javadoc.jar ${APIDOC_ROOT}/
    #Symbolic link to the javadoc, needed by the Wiki
    cd ${APIDOC_ROOT}
    rm -rf last
    ln -s ${VERSION} last
    cd -

         
    echo "-- Push the changes and the tags --"
    git checkout develop
    git branch -d release/$VERSION    
    git push origin :release/$VERSION
    git push
    git push origin --tags

    echo "-- Notify the website for release ${VERSION} --"
    ./bump_release.sh site ${VERSION}
    ;;
    *)
        echo "Unsupported operation '$1'"
        exit 1
esac
back to top