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