Add version bump job
[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 # Check if git state is clean
26 git status
27
28 lftools version release "$RELEASE_TAG"
29 lftools version bump "$RELEASE_TAG"
30
31 git submodule foreach "git commit -asm 'Bump versions by x.y.(z+1)'"
32 # Only submodules need to be bumped, we can ignore autorelease's bump information
33 git checkout -f
34
35 # Generate git patches
36 patch_dir="$WORKSPACE/archives/patches/version-bump"
37 mkdir -p "$patch_dir"
38 for module in $(git submodule | awk '{ print $2 }')
39 do
40     pushd "$module"
41     git format-patch --stdout "origin/${BRANCH,,}" > "$patch_dir/${module//\//-}.patch"
42     git bundle create "$patch_dir/${module//\//-}.bundle" "origin/${BRANCH,,}..HEAD"
43     popd
44 done
45
46 # Verify
47 {
48     echo "----> Verify version bump"
49     git submodule foreach git show HEAD
50     git show HEAD
51     find . -name pom.xml -print0 | xargs -0 grep "$RELEASE_TAG" || true
52     git status
53     ls "$patch_dir"
54 } | tee -a "$LOG_FILE"
55
56 # Push
57 if [ "$DRY_RUN" = "false" ]
58 then
59     # Run a build here! Should be safe to run mvn clean deploy as nothing should be
60     # using the version bumped versions just yet.
61     ./scripts/fix-relativepaths.sh
62     "$MVN" clean install -Pq \
63     -s "$SETTINGS_FILE" \
64     -gs "$GLOBAL_SETTINGS_FILE" \
65     --show-version \
66     --batch-mode \
67     -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
68     -Djenkins \
69     -Dmaven.repo.local=/tmp/r \
70     -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r
71
72     # Push up patches last, as long as nothing failed.
73     git submodule foreach "git remote add gerrit '$GIT_URL/$PROJECT'"
74     git submodule foreach "git review --yes -t '${RELEASE_TAG}' || true"
75 fi
76
77 echo "Version bumping complete."