Use lf-infra-parameters
[releng/builder.git] / jjb / autorelease / prepare-release.sh
1 #!/bin/bash
2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
3 ##############################################################################
4 # Copyright (c) 2015, 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 # Script to prepare project for release.
12 #
13 # 1) Drop -SNAPSHOT from all versions
14 # 2) Create git patches (diffs of changes)
15 # 3) Create git bundles (byte exact commit objects)
16 # 4) Create tarball for distribution.
17
18 # RELEASE_TAG=Beryllium-SR1  # Example
19
20 # Set release tag as $STREAM, when no release tag is passed
21 RELEASE_TAG="${RELEASE_TAG:-${STREAM^}}"
22 # Ensure that the first letter of RELEASE_TAG is uppercase.
23 RELEASE_TAG="${RELEASE_TAG^}"
24
25 # Directory to put git format-patches
26 PATCH_DIR="$WORKSPACE/patches"
27
28 echo "$RELEASE_TAG"
29 # Remove this case statement when Carbon is no longer supported.
30 # Nitrogen onwards we do not want to use the release tag so simply need to
31 # strip xml files of -SNAPSHOT tags.
32 case "$RELEASE_TAG" in
33     Boron*|Carbon*)
34         lftools version release "$RELEASE_TAG"
35         ;;
36     *)
37         find . -name "*.xml" -print0 | xargs -0 sed -i 's/-SNAPSHOT//'
38         ;;
39 esac
40 git submodule foreach "git commit -am \"Release $RELEASE_TAG\" || true"
41 git commit -am "Release $RELEASE_TAG"
42
43 mkdir patches
44 # TODO: Fix this workaround so that scripts will ensure that taglist.log exists and archived.
45 mv taglist.log "$PATCH_DIR" || true
46 modules=$(xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' pom.xml)
47 for module in $modules; do
48     pushd "$module"
49     git format-patch --stdout "origin/$BRANCH" > "$PATCH_DIR/${module//\//-}.patch"
50     git bundle create "$PATCH_DIR/${module//\//-}.bundle" "origin/master..HEAD"
51     popd
52 done
53
54 tar cvzf patches.tar.gz -C "$WORKSPACE" patches
55 rm "$PATCH_DIR"/*.bundle