Merge "Revert "Install odl-mdsal-trace in netvirt oxygen csit""
[releng/builder.git] / jjb / autorelease / version-bump.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 # This script performs version bumping activities for an ODL release.
13 echo "---> version-bump.sh"
14
15 # The only purpose of RELEASE_TAG in this script is to set the Gerrit topic.
16 # It is also used as a placeholder for version bumping but gets wiped out
17 # immediately to bump versions by x.y.(z+1).
18 RELEASE_TAG="${STREAM^}"
19
20 mkdir -p "$WORKSPACE/archives"
21 LOG_FILE="$WORKSPACE/archives/version-bump.log"
22 BRANCH="$GERRIT_BRANCH"
23
24 # Ensure we fail the job if any steps fail.
25 set -eu -o pipefail
26
27 git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
28
29 # TODO: Simplify once stable/nitrogen is no longer supported.
30 for module in $(git submodule | awk '{ print $2 }')
31 do
32     pushd "$module"
33     if [ "$GERRIT_BRANCH" == "stable/nitrogen" ] && [ "$module" == "yangtools" ]; then
34         git checkout -b "v1.2.x" "origin/v1.2.x"
35     else
36         git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
37     fi
38     popd
39 done
40
41 # Setup Gerrit remove to ensure Change-Id gets set on commit.
42 git config --global --add gitreview.username "jenkins-releng"
43 git review -s
44 git submodule foreach "git review -s"
45
46 # Check if git state is clean
47 git status
48
49 lftools version release "$RELEASE_TAG"
50 lftools version bump "$RELEASE_TAG"
51
52 git submodule foreach "git commit -asm 'Bump versions by x.y.(z+1)'"
53 # Only submodules need to be bumped, we can ignore autorelease's bump information
54 git checkout -f
55
56 # Generate git patches
57 patch_dir="$WORKSPACE/archives/patches/version-bump"
58 mkdir -p "$patch_dir"
59 for module in $(git submodule | awk '{ print $2 }')
60 do
61     pushd "$module"
62     # TODO: Remove once stable/nitrogen is no longer supported.
63     if [ "$GERRIT_BRANCH" == "stable/nitrogen" ] && [ "$module" == "yangtools" ]; then
64         git format-patch --stdout "origin/v1.2.x" > "$patch_dir/${module//\//-}.patch"
65         git bundle create "$patch_dir/${module//\//-}.bundle" "origin/v1.2.x..HEAD"
66     else
67         git format-patch --stdout "origin/${BRANCH,,}" > "$patch_dir/${module//\//-}.patch"
68         git bundle create "$patch_dir/${module//\//-}.bundle" "origin/${BRANCH,,}..HEAD"
69     fi
70     popd
71 done
72
73 ##########
74 # Verify #
75 ##########
76
77 {
78     echo "----> Verify version bump"
79     git submodule foreach git show HEAD
80     git show HEAD
81     find . -name pom.xml -print0 | xargs -0 grep "$RELEASE_TAG" || true
82     git status
83     ls "$patch_dir"
84 } | tee -a "$LOG_FILE"
85
86 #########
87 # Build #
88 #########
89
90 MVN_GOALS=(clean install)
91 if [ "$DRY_RUN" = "false" ]
92 then
93     # Should be safe to run mvn clean deploy as nothing should be
94     # using the version bumped versions just yet.
95     MVN_GOALS=(clean deploy)
96 fi
97
98 ./scripts/fix-relativepaths.sh
99 "$MVN" "${MVN_GOALS[@]}" -Pq \
100 -s "$SETTINGS_FILE" \
101 -gs "$GLOBAL_SETTINGS_FILE" \
102 -DaltDeploymentRepository="opendaylight-snapshot::default::https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot" \
103 --show-version \
104 --batch-mode \
105 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
106 -Djenkins \
107 -Dmaven.repo.local=/tmp/r \
108 -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
109
110 # Clear any changes caused by Maven build
111 git checkout -f
112 git submodule foreach git checkout -f
113
114 ########
115 # Push #
116 ########
117
118 if [ "$DRY_RUN" = "false" ]
119 then
120     # Push up patches last, as long as nothing failed.
121     git submodule foreach git review --yes -t "${RELEASE_TAG}"
122 fi
123
124 echo "Version bumping complete."