File: release-jetty.sh

package info (click to toggle)
jetty9 9.4.58-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,128 kB
  • sloc: java: 442,608; xml: 25,460; javascript: 1,039; sh: 912; jsp: 268; sql: 40; makefile: 16
file content (211 lines) | stat: -rwxr-xr-x 7,050 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/bin/bash

echo ""
echo "-----------------------------------------------"
echo "  Verify Environment"

requiredExecutable() {
    hash $1 2>/dev/null 
    if [ $? != 0 ] ; then
        echo "ERROR: $1 not found.  Install $1"
        exit -1
    fi
}

requiredExecutable "git"
requiredExecutable "xmllint"
requiredExecutable "sed"
requiredExecutable "gpg"
requiredExecutable "egrep"
requiredExecutable "mvn"

proceedyn() {
    while true; do
        read -p "$1 " yn
        case ${yn:-$2} in
            [Yy]* ) return 0;;
            [Nn]* ) return 1;;
            * ) echo "Please answer yes or no.";;
        esac
    done
}

echo ""
echo "-----------------------------------------------"
echo "  Collect Information About Release"

function gitFindRemoteByUrl() {
    URL="$1"
    for GREMOTE in $(git remote); do
        git ls-remote --get-url $GREMOTE | grep "$URL" 2>&1 > /dev/null
        if [ $? -eq 0 ] ; then
            echo $GREMOTE
        fi
    done
    return 0
}

GIT_REMOTE_URL="github.com:jetty/jetty.project.git"
GIT_REMOTE_ID=$(gitFindRemoteByUrl "$GIT_REMOTE_URL")
GIT_BRANCH_ID=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)

if [ -z "$GIT_REMOTE_ID" ] ; then
    echo "ERROR: Unable to determine git remote id for $GIT_REMOTE_URL"
    echo "Are you running this build from a properly cloned git local repository?"
    exit -1
fi

# Ensure that git user is in their gpg key list
GIT_USER_EMAIL=`git config --get user.email`

#gpg -q --list-keys "$GIT_USER_EMAIL" 2>&1 > /dev/null
#if [ $? != 0 ] ; then
#    echo "ERROR: git user.email of $GIT_USER_EMAIL is not present in your gpg --list-keys"
#    echo "Go ahead and make one $ gpg --gen-key"
#    exit -1
#fi

VER_CURRENT=`sed -e "s/xmlns/ignore/" pom.xml | xmllint --xpath "/project/version/text()" -`
echo "Current pom.xml Version: ${VER_CURRENT}"
read -e -p "Release Version  ? " VER_RELEASE
read -e -p "Next Dev Version ? " VER_NEXT
read -e -p "Previous Version ? " PREV_VER
TAG_NAME="jetty-$VER_RELEASE"
PREV_TAG="jetty-$PREV_VER"

# Ensure tag doesn't exist (yet)
git rev-parse --quiet --verify "$TAG_NAME" 2>&1 > /dev/null
if [ $? -eq 0 ] ; then
    echo ""
    echo "ERROR: Git Tag $TAG_NAME already exists"
    echo ""
    git show -s "$TAG_NAME"
    exit -1
fi

ALT_DEPLOY_DIR=$HOME/.m2/alt-deploy
if [ ! -d "$ALT_DEPLOY_DIR" ] ; then
    mkdir -p "$ALT_DEPLOY_DIR"
fi

# DEPLOY_OPTS="-Dmaven.test.failure.ignore=true"
DEPLOY_OPTS="-DskipTests -Dtest=None"
# DEPLOY_OPTS="$DEPLOY_OPTS -DaltDeploymentRepository=intarget::default::file://$ALT_DEPLOY_DIR/"

# Uncomment for Java 1.7
# export MAVEN_OPTS="-Xmx1g -XX:MaxPermSize=128m"
export MAVEN_OPTS="-Xmx4g"

echo ""
echo "-----------------------------------------------"
echo "  Release Plan Review"
echo ""
echo "Git Remote ID    : $GIT_REMOTE_ID"
echo "Git Branch ID    : $GIT_BRANCH_ID"
echo "Git user.email   : $GIT_USER_EMAIL"
echo "Current Version  : $VER_CURRENT"
echo "Release Version  : $VER_RELEASE"
echo "Next Dev Version : $VER_NEXT"
echo "Tag name         : $TAG_NAME"
echo "Previous Tag name: $PREV_TAG"
echo "MAVEN_OPTS       : $MAVEN_OPTS"
echo "Maven Deploy Opts: $DEPLOY_OPTS"

reportMavenTestFailures() {
    failFiles=$(egrep -lr --include="*.txt" -E "^Tests .* FAILURE" .)
    oldIFS="$IFS"
    IFS='
'
    IFS=${IFS:0:1}
    failarray=( $failFiles )
    IFS="$oldIFS"

    for index in ${!failarray[@]}; do
        echo ${failarray[index]}
        cat ${failarray[index]}
    done

    if [ ${#failarray[@]} -gt 0 ] ; then
        echo "There are ${#failarray[@]} Test Cases with failures"
    else
        echo "There are no testcases with failures"
    fi
}

echo ""
if proceedyn "Are you sure you want to release using above? (y/N)" n; then
    mvn clean install -pl build-resources
    echo ""
    if proceedyn "Update VERSION.txt for $VER_RELEASE? (Y/n)" y; then
        # Uncomment alternate JVM for jetty 9.2 builds
        # JAVA_HOME_ORIG=$JAVA_HOME
        # PATH_ORIG=$PATH
        # JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
        # PATH=$JAVA_HOME/bin:$PATH
        mvn -N -Pupdate-version generate-resources -Dwebtide.release.tools.releaseVersion=$VER_RELEASE \
            -Dwebtide.release.tools.tagVersionPrior=$PREV_TAG
#        mvn -N -Pupdate-version generate-resources
#        cp VERSION.txt VERSION.txt.backup
#        cat VERSION.txt.backup | sed -e "s/$VER_CURRENT/$VER_RELEASE/" > VERSION.txt
#        rm VERSION.txt.backup
        # JAVA_HOME=$JAVA_HOME_ORIG
        # PATH=$PATH_ORIG
        echo "VERIFY the following files (in a different console window) before continuing."
        echo "   VERSION.txt - top section"
        echo "   target/version-tag.txt - for the tag commit message"
    fi

    # This is equivalent to 'mvn release:prepare'
    if proceedyn "Update project.versions for $VER_RELEASE? (Y/n)" y; then
        mvn org.codehaus.mojo:versions-maven-plugin:2.7:set \
            -DoldVersion="$VER_CURRENT" \
            -DnewVersion="$VER_RELEASE" \
            -DgenerateBackupPoms=false \
            -DprocessAllModules=true 
    fi
    if proceedyn "Commit $VER_RELEASE updates? (Y/n)" y; then
        git commit -a -m "Updating to version $VER_RELEASE"
    fi
    if proceedyn "Create Tag $TAG_NAME? (Y/n)" y; then
        echo "TODO: Sign tags with GIT_USER_EMAIL=$GIT_USER_EMAIL"
        echo "Using target/version-tag.txt as tag text"
        git tag --file=target/version-tag.txt $TAG_NAME
    fi

    # This is equivalent to 'mvn release:perform'
    if proceedyn "Build/Deploy from tag $TAG_NAME? (Y/n)" y; then
        mvn clean deploy -Peclipse-release $DEPLOY_OPTS
        mvn njord:publish -Ddrop=false $DEPLOY_OPTS
    fi
    if proceedyn "Update working directory for $VER_NEXT? (Y/n)" y; then
        echo "Update project.versions for $VER_NEXT"
        mvn org.codehaus.mojo:versions-maven-plugin:2.7:set \
            -DoldVersion="$VER_RELEASE" \
            -DnewVersion="$VER_NEXT" \
            -DgenerateBackupPoms=false \
            -DprocessAllModules=true 
        echo "Commit $VER_NEXT"
        if proceedyn "Commit updates in working directory for $VER_NEXT? (Y/n)" y; then
            git commit -a -m "Updating to version $VER_NEXT"
        fi
    fi
    if proceedyn "Push git commits to remote $GIT_REMOTE_ID? (Y/n)" y; then
        git push $GIT_REMOTE_ID $GIT_BRANCH_ID
        git push $GIT_REMOTE_ID $TAG_NAME
    fi

    if proceedyn "Do you want to build changelog.md in target/changelog.md? (Y/n)" y; then
        mvn -N net.webtide.tools:webtide-release-tools-plugin:gh-release \
            -Dwebtide.release.tools.refVersionCurrent=$TAG_NAME \
            -Dwebtide.release.tools.tagVersionPrior=$PREV_TAG -e
    fi

    # here we need to add something to publish to our staging repo
    # mvn njord:publish -Ddrop=false -Dpublisher=deploy -DaltDeploymentRepository=jetty-staging::http://localhost:8081/repository/release-staging
    # need an entry in settings.xml for id jetty-staging

else
    echo "Not performing release"
fi