Merge "Revert "Make packer jobs build sequentially""
[releng/builder.git] / jjb / autorelease / version-bump.sh
1 #!/bin/bash
2 # @License EPL-1.0 <http://spdx.org/licenses/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 mkdir -p "$WORKSPACE/archives"
16 LOG_FILE="$WORKSPACE/archives/version-bump.log"
17 BRANCH="$GERRIT_BRANCH"
18
19 # Ensure we fail the job if any steps fail.
20 set -eu -o pipefail
21
22 git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
23 git submodule foreach git checkout -b "${BRANCH,,}" "origin/${BRANCH,,}"
24
25 # Setup Gerrit remove to ensure Change-Id gets set on commit.
26 git config --global --add gitreview.username "jenkins-releng"
27 git review -s
28 git submodule foreach "git review -s"
29
30 # Check if git state is clean
31 git status
32
33 lftools version release "$RELEASE_TAG"
34 lftools version bump "$RELEASE_TAG"
35
36 git submodule foreach "git commit -asm 'Bump versions by x.y.(z+1)'"
37 # Only submodules need to be bumped, we can ignore autorelease's bump information
38 git checkout -f
39
40 # Generate git patches
41 patch_dir="$WORKSPACE/archives/patches/version-bump"
42 mkdir -p "$patch_dir"
43 for module in $(git submodule | awk '{ print $2 }')
44 do
45     pushd "$module"
46     git format-patch --stdout "origin/${BRANCH,,}" > "$patch_dir/${module//\//-}.patch"
47     git bundle create "$patch_dir/${module//\//-}.bundle" "origin/${BRANCH,,}..HEAD"
48     popd
49 done
50
51 # Verify
52 {
53     echo "----> Verify version bump"
54     git submodule foreach git show HEAD
55     git show HEAD
56     find . -name pom.xml -print0 | xargs -0 grep "$RELEASE_TAG" || true
57     git status
58     ls "$patch_dir"
59 } | tee -a "$LOG_FILE"
60
61 # Push
62 if [ "$DRY_RUN" = "false" ]
63 then
64     # Run a build here! Should be safe to run mvn clean deploy as nothing should be
65     # using the version bumped versions just yet.
66     ./scripts/fix-relativepaths.sh
67     "$MVN" clean deploy -Pq \
68     -s "$SETTINGS_FILE" \
69     -gs "$GLOBAL_SETTINGS_FILE" \
70     -DaltDeploymentRepository="opendaylight-snapshot::default::https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot" \
71     --show-version \
72     --batch-mode \
73     -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
74     -Djenkins \
75     -Dmaven.repo.local=/tmp/r \
76     -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
77
78     # Clear any changes caused by Maven build
79     git checkout -f
80     git submodule foreach git checkout -f
81
82     # Push up patches last, as long as nothing failed.
83     git submodule foreach git review --yes -t "${RELEASE_TAG}"
84 fi
85
86 echo "Version bumping complete."