Merge "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/archives/patches"
27 mkdir -p "$PATCH_DIR"
28
29 echo "$RELEASE_TAG"
30 # Remove this case statement when Carbon is no longer supported.
31 # Nitrogen onwards we do not want to use the release tag so simply need to
32 # strip xml files of -SNAPSHOT tags.
33 case "$RELEASE_TAG" in
34     Boron*|Carbon*)
35         lftools version release "$RELEASE_TAG"
36         ;;
37     *)
38         find . -name "*.xml" -print0 | xargs -0 sed -i 's/-SNAPSHOT//'
39         ;;
40 esac
41 git submodule foreach "git commit -am \"Release $RELEASE_TAG\" || true"
42 git commit -am "Release $RELEASE_TAG"
43
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 "$PATCH_DIR/patches.tar.gz" -C "$WORKSPACE/archives" patches
55 rm "$PATCH_DIR"/*.bundle